Beispiel #1
0
 /**
  * @param AdministratorEvent $event
  */
 public function delete(AdministratorEvent $event)
 {
     if (null !== ($administrator = AdminQuery::create()->findPk($event->getId()))) {
         $administrator->delete();
         $event->setAdministrator($administrator);
     }
 }
 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]);
     }
 }
Beispiel #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());
 }
 protected function getDeleteEvent()
 {
     $event = new AdministratorEvent();
     $event->setId($this->getRequest()->get('administrator_id', 0));
     return $event;
 }
 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());
 }
 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());
 }