start creating test for Area action
This commit is contained in:
@@ -38,6 +38,8 @@ class AreaCreateEvent extends AreaEvent
|
|||||||
public function setAreaName($name)
|
public function setAreaName($name)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ use Thelia\Core\Event\ActionEvent;
|
|||||||
*/
|
*/
|
||||||
class AreaEvent extends ActionEvent
|
class AreaEvent extends ActionEvent
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var \Thelia\Model\Area
|
||||||
|
*/
|
||||||
protected $area;
|
protected $area;
|
||||||
|
|
||||||
public function __construct($area = null)
|
public function __construct($area = null)
|
||||||
@@ -51,7 +54,7 @@ class AreaEvent extends ActionEvent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return null|\Thelia\Model\Area
|
||||||
*/
|
*/
|
||||||
public function getArea()
|
public function getArea()
|
||||||
{
|
{
|
||||||
|
|||||||
57
core/lib/Thelia/Tests/Action/AreaTest.php
Normal file
57
core/lib/Thelia/Tests/Action/AreaTest.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
/*************************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* Thelia */
|
||||||
|
/* */
|
||||||
|
/* Copyright (c) OpenStudio */
|
||||||
|
/* email : info@thelia.net */
|
||||||
|
/* web : http://www.thelia.net */
|
||||||
|
/* */
|
||||||
|
/* This program is free software; you can redistribute it and/or modify */
|
||||||
|
/* it under the terms of the GNU General Public License as published by */
|
||||||
|
/* the Free Software Foundation; either version 3 of the License */
|
||||||
|
/* */
|
||||||
|
/* This program is distributed in the hope that it will be useful, */
|
||||||
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||||
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||||
|
/* GNU General Public License for more details. */
|
||||||
|
/* */
|
||||||
|
/* You should have received a copy of the GNU General Public License */
|
||||||
|
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
/* */
|
||||||
|
/*************************************************************************************/
|
||||||
|
|
||||||
|
namespace Thelia\Tests\Action;
|
||||||
|
|
||||||
|
use Thelia\Action\Area;
|
||||||
|
use Thelia\Core\Event\Area\AreaCreateEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AreaTest
|
||||||
|
* @package Thelia\Tests\Action
|
||||||
|
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||||
|
*/
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user