diff --git a/core/lib/Thelia/Core/Event/Area/AreaCreateEvent.php b/core/lib/Thelia/Core/Event/Area/AreaCreateEvent.php index 32dc7a6c8..d833b4128 100644 --- a/core/lib/Thelia/Core/Event/Area/AreaCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Area/AreaCreateEvent.php @@ -38,6 +38,8 @@ class AreaCreateEvent extends AreaEvent public function setAreaName($name) { $this->name = $name; + + return $this; } /** diff --git a/core/lib/Thelia/Core/Event/Area/AreaEvent.php b/core/lib/Thelia/Core/Event/Area/AreaEvent.php index 9e0c2dc00..6c951335a 100644 --- a/core/lib/Thelia/Core/Event/Area/AreaEvent.php +++ b/core/lib/Thelia/Core/Event/Area/AreaEvent.php @@ -31,6 +31,9 @@ use Thelia\Core\Event\ActionEvent; */ class AreaEvent extends ActionEvent { + /** + * @var \Thelia\Model\Area + */ protected $area; public function __construct($area = null) @@ -51,7 +54,7 @@ class AreaEvent extends ActionEvent } /** - * @return mixed + * @return null|\Thelia\Model\Area */ public function getArea() { diff --git a/core/lib/Thelia/Tests/Action/AreaTest.php b/core/lib/Thelia/Tests/Action/AreaTest.php new file mode 100644 index 000000000..a67ebc205 --- /dev/null +++ b/core/lib/Thelia/Tests/Action/AreaTest.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Action; + +use Thelia\Action\Area; +use Thelia\Core\Event\Area\AreaCreateEvent; + + +/** + * Class AreaTest + * @package Thelia\Tests\Action + * @author Manuel Raynaud + */ +class AreaTest extends \PHPUnit_Framework_TestCase +{ + + public function testCreate() + { + $event = new AreaCreateEvent(); + $event + ->setAreaName('foo') + ->setDispatcher($this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface")); + + $areaAction = new Area(); + $areaAction->create($event); + + $createdArea = $event->getArea(); + + $this->assertInstanceOf('Thelia\Model\Area', $createdArea); + $this->assertFalse($createdArea->isNew()); + $this->assertTrue($event->hasArea()); + + $this->assertEquals('foo', $createdArea->getName()); + } + +} \ No newline at end of file