public function testSet() { $name = 'testName'; $value = 'testValue'; $this->userScopeManager->expects($this->once())->method('set')->with($name, $value); $this->manager->set($name, $value); }
/** * {@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(); } }
public function testRegisterWithConfirmation() { $this->configManager->set('oro_b2b_account.confirmation_required', true); $crawler = $this->client->request('GET', $this->getUrl('orob2b_account_frontend_account_user_register')); $result = $this->client->getResponse(); $this->assertHtmlResponseStatusCodeEquals($result, 200); $this->submitRegisterForm($crawler, self::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(self::EMAIL, key($message->getTo())); $this->assertContains('Confirmation of account registration', $message->getSubject()); $user = $this->getAccountUser(['email' => self::EMAIL]); $confirmMessage = 'Please follow this link to confirm your email address: <a href="' . trim($this->configManager->get('oro_ui.application_url'), '/') . htmlspecialchars($this->getUrl('orob2b_account_frontend_account_user_confirmation', ['username' => $user->getUsername(), 'token' => $user->getConfirmationToken()])) . '">Confirm</a>'; $this->assertContains($confirmMessage, $message->getBody()); $user = $this->getAccountUser(['email' => self::EMAIL]); $this->assertNotEmpty($user); $this->assertTrue($user->isEnabled()); $this->assertFalse($user->isConfirmed()); $crawler = $this->client->followRedirect(); $this->assertEquals('Login', $crawler->filter('h2.title')->html()); $this->assertContains('Please check your email to complete registration', $crawler->html()); $this->client->followRedirects(true); // Follow confirmation link $crawler = $this->client->request('GET', $this->getUrl('orob2b_account_frontend_account_user_confirmation', ['username' => $user->getUsername(), 'token' => $user->getConfirmationToken()])); $result = $this->client->getResponse(); $this->assertHtmlResponseStatusCodeEquals($result, 200); $this->assertContains('Login', $crawler->html()); $user = $this->getAccountUser(['email' => self::EMAIL]); $this->assertNotEmpty($user); $this->assertTrue($user->isEnabled()); $this->assertTrue($user->isConfirmed()); }