diff --git a/core/lib/Thelia/Action/Administrator.php b/core/lib/Thelia/Action/Administrator.php
index 5c34e2c59..bbd4e3336 100644
--- a/core/lib/Thelia/Action/Administrator.php
+++ b/core/lib/Thelia/Action/Administrator.php
@@ -30,7 +30,7 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Admin as AdminModel;
use Thelia\Model\AdminQuery;
-class Administrator extends BaseAction implements EventSubscriberInterface
+class Administrator implements EventSubscriberInterface
{
/**
* @param AdministratorEvent $event
@@ -40,7 +40,7 @@ class Administrator extends BaseAction implements EventSubscriberInterface
$administrator = new AdminModel();
$administrator
- ->setDispatcher($this->getDispatcher())
+ ->setDispatcher($event->getDispatcher())
->setFirstname($event->getFirstname())
->setLastname($event->getLastname())
->setLogin($event->getLogin())
@@ -62,7 +62,7 @@ class Administrator extends BaseAction implements EventSubscriberInterface
if (null !== $administrator = AdminQuery::create()->findPk($event->getId())) {
$administrator
- ->setDispatcher($this->getDispatcher())
+ ->setDispatcher($event->getDispatcher())
->setFirstname($event->getFirstname())
->setLastname($event->getLastname())
->setLogin($event->getLogin())
diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml
index e2a6ce72b..c64e606a8 100644
--- a/core/lib/Thelia/Config/Resources/action.xml
+++ b/core/lib/Thelia/Config/Resources/action.xml
@@ -155,7 +155,6 @@
-
diff --git a/core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.php b/core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.php
index 48ff97be8..0071526dc 100644
--- a/core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.php
+++ b/core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.php
@@ -62,6 +62,8 @@ class AdministratorEvent extends ActionEvent
public function setId($id)
{
$this->id = $id;
+
+ return $this;
}
public function getId()
@@ -72,6 +74,8 @@ class AdministratorEvent extends ActionEvent
public function setFirstname($firstname)
{
$this->firstname = $firstname;
+
+ return $this;
}
public function getFirstname()
@@ -82,6 +86,8 @@ class AdministratorEvent extends ActionEvent
public function setLastname($lastname)
{
$this->lastname = $lastname;
+
+ return $this;
}
public function getLastname()
@@ -92,6 +98,8 @@ class AdministratorEvent extends ActionEvent
public function setLogin($login)
{
$this->login = $login;
+
+ return $this;
}
public function getLogin()
@@ -102,6 +110,8 @@ class AdministratorEvent extends ActionEvent
public function setPassword($password)
{
$this->password = $password;
+
+ return $this;
}
public function getPassword()
@@ -112,6 +122,8 @@ class AdministratorEvent extends ActionEvent
public function setProfile($profile)
{
$this->profile = $profile;
+
+ return $this;
}
public function getProfile()
diff --git a/core/lib/Thelia/Tests/Action/AddressTest.php b/core/lib/Thelia/Tests/Action/AddressTest.php
index ac74acec5..b570959e0 100644
--- a/core/lib/Thelia/Tests/Action/AddressTest.php
+++ b/core/lib/Thelia/Tests/Action/AddressTest.php
@@ -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();
diff --git a/core/lib/Thelia/Tests/Action/AdministratorTest.php b/core/lib/Thelia/Tests/Action/AdministratorTest.php
new file mode 100644
index 000000000..9fdf8f70d
--- /dev/null
+++ b/core/lib/Thelia/Tests/Action/AdministratorTest.php
@@ -0,0 +1,70 @@
+. */
+/* */
+/*************************************************************************************/
+
+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
+ */
+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()));
+ }
+
+
+}
\ No newline at end of file