/** * Process form * * @param AccountUser $accountUser * @return bool True on successful processing, false otherwise */ public function process(AccountUser $accountUser) { if (in_array($this->request->getMethod(), ['POST', 'PUT'], true)) { $this->form->submit($this->request); if ($this->form->isValid()) { if (!$accountUser->getId()) { if ($this->form->get('passwordGenerate')->getData()) { $generatedPassword = $this->userManager->generatePassword(10); $accountUser->setPlainPassword($generatedPassword); } if ($this->form->get('sendEmail')->getData()) { $this->userManager->sendWelcomeEmail($accountUser); } } $token = $this->securityContext->getToken(); if ($token instanceof OrganizationContextTokenInterface) { $organization = $token->getOrganizationContext(); $accountUser->setOrganization($organization)->addOrganization($organization); } $this->userManager->updateUser($accountUser); return true; } } return false; }
/** * {@inheritdoc} */ public function testProcessValidDataExistingUser() { $this->entity->expects($this->once())->method('getId')->will($this->returnValue(42)); $this->request->setMethod('POST'); $this->form->expects($this->once())->method('submit')->with($this->request); $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true)); $this->userManager->expects($this->never())->method('register')->with($this->entity); $this->userManager->expects($this->once())->method('updateUser')->with($this->entity); $this->userManager->expects($this->once())->method('reloadUser')->with($this->entity); $this->assertTrue($this->handler->process($this->entity)); }
/** * Process form * * @param AccountUser $accountUser * @return bool True on successful processing, false otherwise */ public function process(AccountUser $accountUser) { if (in_array($this->request->getMethod(), ['POST', 'PUT'], true)) { $this->form->submit($this->request); if ($this->form->isValid()) { if (!$accountUser->getId()) { $this->userManager->register($accountUser); } $this->userManager->updateUser($accountUser); $this->userManager->reloadUser($accountUser); return true; } } return false; }
/** * @dataProvider requiredDataProvider * @param bool $required */ public function testIsConfirmationRequired($required) { $this->configManager->expects($this->once())->method('get')->with('oro_b2b_customer.confirmation_required')->will($this->returnValue($required)); $this->assertEquals($required, $this->userManager->isConfirmationRequired()); }