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