create test for admin modification listener
This commit is contained in:
@@ -25,6 +25,7 @@ namespace Thelia\Tests\Action;
|
|||||||
|
|
||||||
use Thelia\Action\Administrator;
|
use Thelia\Action\Administrator;
|
||||||
use Thelia\Core\Event\Administrator\AdministratorEvent;
|
use Thelia\Core\Event\Administrator\AdministratorEvent;
|
||||||
|
use Thelia\Model\AdminQuery;
|
||||||
use Thelia\Model\LangQuery;
|
use Thelia\Model\LangQuery;
|
||||||
|
|
||||||
|
|
||||||
@@ -66,5 +67,38 @@ class AdministratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertTrue(password_verify($adminEvent->getPassword(), $createdAdmin->getPassword()));
|
$this->assertTrue(password_verify($adminEvent->getPassword(), $createdAdmin->getPassword()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testUpdate()
|
||||||
|
{
|
||||||
|
$admin = AdminQuery::create()->findOne();
|
||||||
|
|
||||||
|
$login = 'thelia'.uniqid();
|
||||||
|
$locale = LangQuery::create()->findOne()->getLocale();
|
||||||
|
$adminEvent = new AdministratorEvent();
|
||||||
|
$adminEvent
|
||||||
|
->setId($admin->getId())
|
||||||
|
->setFirstname('thelia_update')
|
||||||
|
->setLastname('thelia_update')
|
||||||
|
->setLogin($login)
|
||||||
|
->setPassword('azertyuiop')
|
||||||
|
->setLocale($locale)
|
||||||
|
->setDispatcher($this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"))
|
||||||
|
;
|
||||||
|
|
||||||
|
$actionAdmin = new Administrator();
|
||||||
|
$actionAdmin->update($adminEvent);
|
||||||
|
|
||||||
|
$updatedAdmin = $adminEvent->getAdministrator();
|
||||||
|
|
||||||
|
$this->assertInstanceOf("Thelia\Model\Admin", $updatedAdmin);
|
||||||
|
$this->assertFalse($updatedAdmin->isNew());
|
||||||
|
|
||||||
|
$this->assertEquals($adminEvent->getFirstname(), $updatedAdmin->getFirstname());
|
||||||
|
$this->assertEquals($adminEvent->getLastname(), $updatedAdmin->getLastname());
|
||||||
|
$this->assertEquals($adminEvent->getLogin(), $updatedAdmin->getLogin());
|
||||||
|
$this->assertEquals($adminEvent->getLocale(), $updatedAdmin->getLocale());
|
||||||
|
$this->assertEquals($adminEvent->getProfile(), $updatedAdmin->getProfileId());
|
||||||
|
$this->assertTrue(password_verify($adminEvent->getPassword(), $updatedAdmin->getPassword()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user