public function testSerieWithInvalidTokenResets() { $this->assumeSerie($correctSerie = new SerieToken(3, 'abc', 'def')); $correctSerie->setExpiresAt(new \DateTime('tomorrow')); $falseSerie = new SerieToken(3, 'abc', 'gdaf'); $this->mapper->expects($this->once())->method('remove')->with($correctSerie); $nextSerie = $this->service->getNextInSerie($falseSerie); $this->assertNull($nextSerie); }
public function testGeneratesSerieToken() { $event = new AdapterChainEvent(); $event->setIdentity(3); $returnToken = new SerieToken(3, 'abc', 'def'); $returnToken->setExpiresAt(new \DateTime('+3 days')); $this->rememberMeService->expects($this->once())->method('createNew')->with(3)->will($this->returnValue($returnToken)); $this->cookieService->expects($this->once())->method('writeSerie')->with($this->response, $returnToken); $this->listener->authenticate($event); }
public function testWriteSerie() { $serie = new SerieToken(3, 'abc', 'def'); $serie->setExpiresAt(new \DateTime('+1 year')); $response = new Response(); $this->service->writeSerie($response, $serie); $this->assertTrue($response->getHeaders()->has('SetCookie')); $cookie = $response->getHeaders()->get('SetCookie')->current(); $this->assertInstanceOf('Zend\\Http\\Header\\SetCookie', $cookie); $this->assertEquals('JwPersistentUser', $cookie->getName()); $this->assertEquals('3:abc:def', $cookie->getValue()); $this->assertDateTimeEquals(new \DateTime('+1 year'), new \DateTime($cookie->getExpires())); $this->assertEquals('/', $cookie->getPath()); }