remove container from administrator listener and create test for this
event. #198
This commit is contained in:
@@ -109,7 +109,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase
|
||||
$addressEvent->setAddress($address);
|
||||
$addressEvent->setDispatcher($this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"));
|
||||
|
||||
$actionAddress = new Address($this->getContainer());
|
||||
$actionAddress = new Address();
|
||||
$actionAddress->update($addressEvent);
|
||||
|
||||
$updatedAddress = $addressEvent->getAddress();
|
||||
|
||||
70
core/lib/Thelia/Tests/Action/AdministratorTest.php
Normal file
70
core/lib/Thelia/Tests/Action/AdministratorTest.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?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\Administrator;
|
||||
use Thelia\Core\Event\Administrator\AdministratorEvent;
|
||||
use Thelia\Model\LangQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class AdministratorTest
|
||||
* @package Thelia\Tests\Action
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class AdministratorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$login = 'thelia'.uniqid();
|
||||
$locale = LangQuery::create()->findOne()->getLocale();
|
||||
$adminEvent = new AdministratorEvent();
|
||||
$adminEvent
|
||||
->setFirstname('thelia')
|
||||
->setLastname('thelia')
|
||||
->setLogin($login)
|
||||
->setPassword('azerty')
|
||||
->setLocale($locale)
|
||||
->setDispatcher($this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"))
|
||||
;
|
||||
|
||||
$admin = new Administrator();
|
||||
$admin->create($adminEvent);
|
||||
|
||||
$createdAdmin = $adminEvent->getAdministrator();
|
||||
|
||||
$this->assertInstanceOf("Thelia\Model\Admin", $createdAdmin);
|
||||
$this->assertFalse($createdAdmin->isNew());
|
||||
|
||||
$this->assertEquals($adminEvent->getFirstname(), $createdAdmin->getFirstname());
|
||||
$this->assertEquals($adminEvent->getLastname(), $createdAdmin->getLastname());
|
||||
$this->assertEquals($adminEvent->getLogin(), $createdAdmin->getLogin());
|
||||
$this->assertEquals($adminEvent->getLocale(), $createdAdmin->getLocale());
|
||||
$this->assertEquals($adminEvent->getProfile(), $createdAdmin->getProfileId());
|
||||
$this->assertTrue(password_verify($adminEvent->getPassword(), $createdAdmin->getPassword()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user