public function testValidTokenIsValid()
 {
     $random = $this->getMockBuilder('random')->disableOriginalConstructor()->setMethods(['helloToken'])->getMock();
     $token = \random::generatePassword();
     $random->expects($this->once())->method('helloToken')->with($token)->will($this->returnValue(['usr_id' => mt_rand(), 'type' => \random::TYPE_PASSWORD]));
     $constraint = new PasswordToken($random);
     $this->assertTrue($constraint->isValid($token));
 }
Exemplo n.º 2
0
 public function testValidTokenIsValid()
 {
     $repo = $this->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->setMethods(['findValidToken'])->getMock();
     $tokenValue = self::$DI['app']['random.low']->generateString(8);
     $token = new Token();
     $token->setType(TokenManipulator::TYPE_PASSWORD);
     $repo->expects($this->once())->method('findValidToken')->with($tokenValue)->will($this->returnValue($token));
     $constraint = new PasswordToken($repo);
     $this->assertTrue($constraint->isValid($tokenValue));
 }