protected function sendActivation(User $user) { $subject = "Activation"; $link = $this->generateLink($_SERVER["HTTP_HOST"], $_SERVER["SCRIPT_NAME"], $user->getActivation()); $this->setVar('link', $link); $text = $this->renderPattern('activationMail'); return $this->sendEmail($user->getEmail(), $subject, $text); }
public function saveUser(User $user) { $bcrypt = new Bcrypt(); $securePass = $bcrypt->create($user->getPassword()); $data = array('email' => $user->getEmail(), 'first_name' => $user->getFirstName(), 'last_name' => $user->getLastName(), 'password' => $securePass, 'status' => $user->getStatus()); $idUser = (int) $user->getIdUser(); if (empty($idUser)) { return $this->insert($data); } else { if ($this->getUser($idUser)) { $this->update($data, array('iduser' => $idUser)); } else { throw new \Exception('Usuario não encontrado'); } } }
/** * Assert that the user has the same information as the profile * @param Profile $profile * @param User $user */ private function assertUser(Profile $profile, User $user, $message = null) { $expected = array_filter((array) $profile); // Slighlty adapt expected values unset($expected['identifier']); if (!isset($expected['email'])) { $expected['email'] = null; } $actual = ['photoURL' => $user->getPhoto(), 'displayName' => $user->getName(), 'email' => $user->getEmail(), 'phone' => $user->getPhone(), 'address' => $user->getStreet(), 'city' => $user->getLocality(), 'zip' => $user->getPostcode()]; $this->assertEquals($expected, $actual, $message); }
public function testProfile() { $profile = new Profile(); $profile->identifier = 'identifier'; $profile->webSiteURL = 'webSiteURL'; $profile->profileURL = 'profileURL'; $profile->photoURL = 'photoURL'; $profile->displayName = 'displayName'; $profile->description = 'description'; $profile->firstName = 'firstName'; $profile->lastName = 'lastName'; $profile->gender = 'male'; $profile->language = 'language'; $profile->age = 'age'; $profile->birthDay = 'birthDay'; $profile->birthMonth = 'birthMonth'; $profile->birthYear = 'birthYear'; $profile->email = 'email'; $profile->emailVerified = 'emailVerified'; $profile->phone = 'phone'; $profile->address = 'address'; $profile->country = 'CH'; $profile->region = 'region'; $profile->city = 'city'; $profile->zip = 'zip'; $country = new Country(); $user = new User(); $user->fromProfile($profile, $country); $this->assertSame('photoURL', $user->getPhoto()); $this->assertSame('description', $user->getDescription()); $this->assertSame('firstName', $user->getFirstname()); $this->assertSame('lastName', $user->getLastname()); $this->assertSame(1, $user->getSex()); $this->assertSame('la', $user->getLanguage()); $this->assertSame('phone', $user->getPhone()); $this->assertSame('address', $user->getStreet()); $this->assertSame($country, $user->getCountry()); $this->assertSame('region', $user->getArea()); $this->assertSame('city', $user->getLocality()); $this->assertSame('zip', $user->getPostcode()); $this->assertSame('email', $user->getEmail()); }