Ejemplo n.º 1
0
 /**
  * @param AdministratorEvent $event
  */
 public function delete(AdministratorEvent $event)
 {
     if (null !== ($administrator = AdminQuery::create()->findPk($event->getId()))) {
         $administrator->delete();
         $event->setAdministrator($administrator);
     }
 }
Ejemplo n.º 2
0
 public function createPassword(AdministratorEvent $event)
 {
     $admin = $event->getAdministrator();
     $email = $admin->getEmail();
     if (!empty($email)) {
         $renewToken = $this->tokenProvider->getToken();
         $admin->setPasswordRenewToken($renewToken)->save();
         $this->mailer->sendEmailMessage('new_admin_password', [ConfigQuery::getStoreEmail() => ConfigQuery::getStoreName()], [$email => $admin->getFirstname() . ' ' . $admin->getLastname()], ['token' => $renewToken, 'admin' => $admin]);
     }
 }
Ejemplo n.º 3
0
 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());
 }
Ejemplo n.º 4
0
 protected function getDeleteEvent()
 {
     $event = new AdministratorEvent();
     $event->setId($this->getRequest()->get('administrator_id', 0));
     return $event;
 }
Ejemplo n.º 5
0
 public function testDelete()
 {
     $admin = AdminQuery::create()->findOne();
     $adminEvent = new AdministratorEvent();
     $adminEvent->setId($admin->getId());
     $actionAdmin = new Administrator($this->mailerFactory, $this->tokenProvider);
     $actionAdmin->delete($adminEvent);
     $deletedAdmin = $adminEvent->getAdministrator();
     $this->assertInstanceOf("Thelia\\Model\\Admin", $deletedAdmin);
     $this->assertTrue($deletedAdmin->isDeleted());
 }
Ejemplo n.º 6
0
 public function testRenewPassword()
 {
     $admin = AdminQuery::create()->findOne();
     $admin->setPasswordRenewToken(null)->setEmail('*****@*****.**')->save();
     $adminEvent = new AdministratorEvent($admin);
     $adminEvent->setDispatcher($this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface"));
     $actionAdmin = new Administrator($this->mailerFactory, $this->tokenProvider);
     $actionAdmin->createPassword($adminEvent);
     $updatedAdmin = $adminEvent->getAdministrator();
     $this->assertInstanceOf("Thelia\\Model\\Admin", $updatedAdmin);
     $this->assertNotEmpty($admin->getPasswordRenewToken());
 }