create test for updatePassword event
This commit is contained in:
@@ -54,6 +54,8 @@ class AdministratorUpdatePasswordEvent extends ActionEvent
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,6 +72,8 @@ class AdministratorUpdatePasswordEvent extends ActionEvent
|
||||
public function setAdmin(Admin $admin)
|
||||
{
|
||||
$this->admin = $admin;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Thelia\Tests\Action;
|
||||
|
||||
use Thelia\Action\Administrator;
|
||||
use Thelia\Core\Event\Administrator\AdministratorEvent;
|
||||
use Thelia\Core\Event\Administrator\AdministratorUpdatePasswordEvent;
|
||||
use Thelia\Model\AdminQuery;
|
||||
use Thelia\Model\LangQuery;
|
||||
|
||||
@@ -100,5 +101,43 @@ class AdministratorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(password_verify($adminEvent->getPassword(), $updatedAdmin->getPassword()));
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$admin = AdminQuery::create()->findOne();
|
||||
|
||||
$adminEvent = new AdministratorEvent();
|
||||
|
||||
$adminEvent
|
||||
->setId($admin->getId())
|
||||
->setDispatcher($this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"))
|
||||
;
|
||||
|
||||
$actionAdmin = new Administrator();
|
||||
$actionAdmin->delete($adminEvent);
|
||||
|
||||
$deletedAdmin = $adminEvent->getAdministrator();
|
||||
|
||||
$this->assertInstanceOf("Thelia\Model\Admin", $deletedAdmin);
|
||||
$this->assertTrue($deletedAdmin->isDeleted());
|
||||
}
|
||||
|
||||
public function testUpdatePassword()
|
||||
{
|
||||
$admin = AdminQuery::create()->findOne();
|
||||
|
||||
$adminEvent = new AdministratorUpdatePasswordEvent($admin);
|
||||
$adminEvent
|
||||
->setPassword('toto')
|
||||
->setDispatcher($this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"));
|
||||
|
||||
$actionAdmin = new Administrator();
|
||||
$actionAdmin->updatePassword($adminEvent);
|
||||
|
||||
$updatedAdmin = $adminEvent->getAdmin();
|
||||
|
||||
$this->assertInstanceOf("Thelia\Model\Admin", $updatedAdmin);
|
||||
$this->assertTrue(password_verify($adminEvent->getPassword(), $updatedAdmin->getPassword()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user