public function testCreateFromForm()
 {
     $model = new Entity();
     $model->setEmailAddress('*****@*****.**');
     $form = $this->getMock('Zend\\Form\\Form');
     $form->expects($this->any())->method('getData')->will($this->returnValue($model));
     $form->expects($this->any())->method('isValid')->will($this->returnValue(true));
     $evrMapper = $this->getMock('CdliTwoStageSignup\\Mapper\\EmailVerification\\MapperInterface');
     $evrMapper->expects($this->once())->method('insert')->with($this->isInstanceOf('CdliTwoStageSignup\\Entity\\EmailVerification'))->will($this->returnValue(NULL));
     $service = new Service();
     $service->setEmailVerificationMapper($evrMapper);
     $result = $service->createFromForm($form);
     $this->assertInstanceOf('CdliTwoStageSignup\\Entity\\EmailVerification', $result);
 }
Exemplo n.º 2
0
 public function testCleanExpiredVerificationRequests()
 {
     $this->importSchema(__DIR__ . '/_files/singlerecord.sql');
     // Add a second, non-expired request
     $m = new Entity();
     $m->setEmailAddress('*****@*****.**');
     $m->generateRequestKey();
     $this->mapper->insert($m);
     $this->mapper->cleanExpiredVerificationRequests();
     $set = $this->db->query('SELECT * FROM ' . $this->db->platform->quoteIdentifier('user_signup_email_verification'))->execute();
     $this->assertEquals(1, $set->count());
     $actualEntity = $set->current();
     $this->assertEquals($m->getRequestKey(), $actualEntity['request_key']);
     $this->assertEquals($m->getEmailAddress(), $actualEntity['email_address']);
     $this->assertEquals($m->getRequestTime()->format('Y-m-d H:i:s'), $actualEntity['request_time']);
 }
 public function testCleanExpiredVerificationRequests()
 {
     $this->importSchema(__DIR__ . '/_files/singlerecord.sql');
     // Add a second, non-expired request
     $m = new Entity();
     $m->setEmailAddress('*****@*****.**');
     $m->generateRequestKey();
     $this->mapper->insert($m);
     $this->mapper->cleanExpiredVerificationRequests();
     $set = $this->getDBALConnection()->executeQuery('SELECT * FROM user_signup_email_verification')->fetchAll();
     $this->assertEquals(1, count($set));
     $actualEntity = array_pop($set);
     $this->assertEquals($m->getRequestKey(), $actualEntity['request_key']);
     $this->assertEquals($m->getEmailAddress(), $actualEntity['email_address']);
     $this->assertEquals($m->getRequestTime()->format('Y-m-d H:i:s'), $actualEntity['request_time']);
 }