Exemplo n.º 1
0
 public function __construct(UserToken $userToken, DTOBuilderFactoryInterface $dtoBuilderFactory)
 {
     $this->entity = $userToken;
     $this->dtoBuilderFactory = $dtoBuilderFactory;
     $this->entityDTO = new UserTokenDTO();
     $this->setId();
     $this->setTime();
     $this->entityDTO->userAgent = $this->entity->getUserAgent();
     $this->entityDTO->ip4 = $this->entity->getIp4();
     $this->entityDTO->expires = $this->entity->getExpires();
     $this->entityDTO->type = $this->dtoBuilderFactory->getUserTokenTypeDTOBuilder($this->entity->getType())->build();
 }
Exemplo n.º 2
0
 public function testCreateDefaults()
 {
     $this->assertEntityValid($this->userToken);
     $this->assertTrue($this->userToken->getId() instanceof UuidInterface);
     $this->assertTrue($this->userToken->getCreated() instanceof DateTime);
     $this->assertSame(self::USER_AGENT, $this->userToken->getUserAgent());
     $this->assertFalse($this->userToken->verifyToken('wrong-token'));
     $this->assertTrue($this->userToken->verifyToken(self::TOKEN));
     $this->assertEntitiesEqual($this->user, $this->userToken->getUser());
     $this->assertEquals($this->expires, $this->userToken->getExpires());
     $this->assertTrue($this->userToken->getType()->isInternal());
 }