/**
  * @dataProvider registerWithoutConfirmationDataProvider
  *
  * @param string $email
  * @param bool $withPassword
  */
 public function testRegisterWithoutConfirmation($email, $withPassword)
 {
     $this->configManager->set('oro_b2b_account.confirmation_required', false);
     $this->configManager->set('oro_b2b_account.send_password_in_welcome_email', $withPassword);
     $this->configManager->flush();
     $crawler = $this->client->request('GET', $this->getUrl('orob2b_account_frontend_account_user_register'));
     $result = $this->client->getResponse();
     $this->assertHtmlResponseStatusCodeEquals($result, 200);
     $this->submitRegisterForm($crawler, $email);
     /** @var MessageDataCollector $collector */
     $collector = $this->client->getProfile()->getCollector('swiftmailer');
     $messages = $collector->getMessages();
     /** @var \Swift_Message $message */
     $message = reset($messages);
     $this->assertInstanceOf('Swift_Message', $message);
     $this->assertEquals($email, key($message->getTo()));
     $this->assertContains($email, $message->getSubject());
     $this->assertContains($email, $message->getBody());
     $this->assertContains(trim($this->configManager->get('oro_ui.application_url'), '/') . $this->getUrl('orob2b_account_account_user_security_login'), $message->getBody());
     if ($withPassword) {
         $this->assertContains(self::PASSWORD, $message->getBody());
     } else {
         $this->assertNotContains(self::PASSWORD, $message->getBody());
     }
     $crawler = $this->client->followRedirect();
     $result = $this->client->getResponse();
     $this->assertHtmlResponseStatusCodeEquals($result, 200);
     $user = $this->getAccountUser(['email' => $email]);
     $this->assertNotEmpty($user);
     $this->assertTrue($user->isEnabled());
     $this->assertTrue($user->isConfirmed());
     $this->assertContains('Registration successful', $crawler->html());
 }
Esempio n. 2
0
 public function testFlush()
 {
     $changes = ['oro_user.greeting' => ['value' => 'updated value', 'use_parent_scope_value' => false]];
     $this->userScopeManager->expects($this->once())->method('getSettingValue')->with('oro_user.greeting', false)->willReturn('old value');
     $beforeEvent = new ConfigSettingsUpdateEvent($this->manager, $changes);
     $afterEvent = new ConfigUpdateEvent(['oro_user.greeting' => ['old' => 'old value', 'new' => 'updated value']]);
     $this->userScopeManager->expects($this->once())->method('getChanges')->willReturn($changes);
     $this->userScopeManager->expects($this->once())->method('save')->with($changes)->willReturn([['oro_user.greeting' => 'updated value'], []]);
     $this->dispatcher->expects($this->exactly(2))->method('dispatch');
     $this->dispatcher->expects($this->at(0))->method('dispatch')->with(ConfigSettingsUpdateEvent::BEFORE_SAVE, $beforeEvent);
     $this->dispatcher->expects($this->at(1))->method('dispatch')->with(ConfigUpdateEvent::EVENT_NAME, $afterEvent);
     $this->manager->flush();
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 protected function onSuccess(User $user)
 {
     $this->manager->updateUser($user);
     if ($this->form->has('inviteUser') && $this->form->has('plainPassword') && $this->form->get('inviteUser')->getViewData() && $this->form->get('plainPassword')->getViewData()) {
         try {
             $this->sendInviteMail($user, $this->form->get('plainPassword')->getViewData()['first']);
         } catch (\Exception $ex) {
             $this->logger->error('Invitation email sending failed.', ['exception' => $ex]);
             $this->flashBag->add('warning', $this->translator->trans('oro.user.controller.invite.fail.message'));
         }
     }
     // Reloads the user to reset its username. This is needed when the
     // username or password have been changed to avoid issues with the
     // security layer.
     // Additional checking for userConfigManager !== null is added because of API
     // to avoid "Call to a member function on a non-object".
     $this->manager->reloadUser($user);
     if ($this->form->has('signature') && $this->userConfigManager !== null) {
         $signature = $this->form->get('signature')->getData();
         if ($signature) {
             $this->userConfigManager->set('oro_email.signature', $signature);
         } else {
             $this->userConfigManager->reset('oro_email.signature');
         }
         $this->userConfigManager->flush();
     }
 }
Esempio n. 4
0
 public function testFlush()
 {
     $this->userScopeManager->expects($this->once())->method('flush');
     $this->manager->flush();
 }