Example #1
0
 public function setUp()
 {
     $this->id = ReminderId::generate();
     $this->email = new Email('*****@*****.**');
     $this->code = ReminderCode::generate();
     $this->timestamp = Carbon::create(2014, 10, 11, 10, 23, 34);
     Carbon::setTestNow($this->timestamp);
     $this->reminder = new Reminder($this->id, $this->email, $this->code);
 }
Example #2
0
 public function setUp()
 {
     parent::setUp();
     $this->user = UserStub::create();
     $this->fixture = ['id' => ReminderId::generate(), 'code' => ReminderCode::generate(), 'email' => new Email('*****@*****.**')];
     $this->users = m::mock('Cffs\\Domain\\Model\\Identity\\UserRepository');
     $this->reminders = m::mock('Cffs\\Domain\\Model\\Identity\\ReminderRepository');
     $this->hasher = m::mock('Cffs\\Domain\\Services\\Identity\\HashingService');
     $this->service = new ReminderService($this->reminders, $this->users, $this->hasher);
 }
Example #3
0
 /**
  * Reset a user's password
  *
  * @param string $email
  * @param string $password
  * @param string $code
  * @throws InvalidValueException
  * @return User;
  */
 public function reset($email, $password, $code)
 {
     if ($this->check($email, $code)) {
         $user = $this->findUserByEmail(Email::fromNative($email));
         $password = $this->hasher->hash(new Password($password));
         $user->resetPassword($password);
         $this->users->update($user);
         $this->reminders->deleteReminderByCode(ReminderCode::fromNative($code));
         return $user;
     }
     throw new InvalidValueException("{$code} is not a valid reminder code");
 }
 /**
  * Delete a Reminder by it's ReminderCode
  *
  * @param ReminderCode $code
  * @return void
  */
 public function deleteReminderByCode(ReminderCode $code)
 {
     $query = $this->em->createQuery('DELETE Cffs\\Domain\\Model\\Identity\\Reminder r WHERE r.code = :code');
     $query->setParameters(['code' => $code->toString()]);
     $query->execute();
 }
Example #5
0
 /** @test */
 public function should_return_as_string()
 {
     $code = ReminderCode::fromNative('D1zcA5ncaEHzmjvCGjJIt3Kd8sGxTTtE7DkathqB');
     $this->assertEquals('D1zcA5ncaEHzmjvCGjJIt3Kd8sGxTTtE7DkathqB', $code->toString());
     $this->assertEquals('D1zcA5ncaEHzmjvCGjJIt3Kd8sGxTTtE7DkathqB', (string) $code);
 }
Example #6
0
 /**
  * Set the Reminder Code
  *
  * @param ReminderCode $code
  * @return void
  */
 private function setCode(ReminderCode $code)
 {
     $this->code = $code->toString();
 }