start creating test for Area action

This commit is contained in:
Manuel Raynaud
2014-02-03 09:13:26 +01:00
parent 220d405142
commit 0c87b7606c
3 changed files with 63 additions and 1 deletions

View File

@@ -38,6 +38,8 @@ class AreaCreateEvent extends AreaEvent
public function setAreaName($name)
{
$this->name = $name;
return $this;
}
/**

View File

@@ -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()
{

View 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());
}
}