예제 #1
0
 /** @test */
 public function should_create_new_reminder_on_request()
 {
     $this->users->shouldReceive('userOfEmail')->once()->andReturn(true);
     $this->reminders->shouldReceive('deleteExistingRemindersForEmail')->once();
     $this->reminders->shouldReceive('nextIdentity')->once()->andReturn(ReminderId::generate());
     $this->reminders->shouldReceive('add')->once();
     $reminder = $this->service->request('*****@*****.**');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\Reminder', $reminder);
 }
예제 #2
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);
 }
 /** @test */
 public function should_add_new_reminder()
 {
     $id = ReminderId::generate();
     $code = ReminderCode::fromNative('new');
     $email = new Email('*****@*****.**');
     $reminder = new Reminder($id, $email, $code);
     $this->repository->add($reminder);
     $this->em->clear();
     $reminder = $this->repository->findReminderByEmailAndCode($email, $code);
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\Reminder', $reminder);
     $this->assertEquals($code, $reminder->code());
     $this->assertEquals($email, $reminder->email());
 }
예제 #4
0
 /**
  * Load the User fixtures
  *
  * @param ObjectManager $manager
  * @return void
  */
 public function load(ObjectManager $manager)
 {
     // Create valid Reminder
     $id = ReminderId::generate();
     $email = new Email('*****@*****.**');
     $code = ReminderCode::fromNative('code+99');
     $reminder = new Reminder($id, $email, $code);
     $manager->persist($reminder);
     // Create expired Reminder
     Carbon::setTestNow(Carbon::create(2014, 10, 11, 10, 23, 34));
     $id = ReminderId::generate();
     $email = new Email('*****@*****.**');
     $code = ReminderCode::fromNative('code+1');
     $reminder = new Reminder($id, $email, $code);
     Carbon::setTestNow();
     $manager->persist($reminder);
     $manager->flush();
 }
예제 #5
0
 /** @test */
 public function should_return_reminder_id_as_string()
 {
     $id = ReminderId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc');
     $this->assertEquals('d16f9fe7-e947-460e-99f6-2d64d65f46bc', $id->toString());
     $this->assertEquals('d16f9fe7-e947-460e-99f6-2d64d65f46bc', (string) $id);
 }
 /**
  * Return the next identity
  *
  * @return ReminderId
  */
 public function nextIdentity()
 {
     return ReminderId::generate();
 }
예제 #7
0
파일: Reminder.php 프로젝트: kfuchs/cribbb
 /**
  * Set the Reminder id
  *
  * @param ReminderId $id
  * @return void
  */
 private function setId(ReminderId $id)
 {
     $this->id = $id->toString();
 }