public function testGenerateToken() { $token = $this->generator->generateToken(); $this->assertTrue(ctype_print($token), 'is printable'); $this->assertStringNotMatchesFormat('%S+%S', $token, 'is URI safe'); $this->assertStringNotMatchesFormat('%S/%S', $token, 'is URI safe'); $this->assertStringNotMatchesFormat('%S=%S', $token, 'is URI safe'); }
public function testGenerateToken() { $this->random->expects($this->once())->method('nextBytes')->with(self::ENTROPY / 8)->will($this->returnValue(self::$bytes)); $token = $this->generator->generateToken(); $this->assertTrue(ctype_print($token), 'is printable'); $this->assertStringNotMatchesFormat('%S+%S', $token, 'is URI safe'); $this->assertStringNotMatchesFormat('%S/%S', $token, 'is URI safe'); $this->assertStringNotMatchesFormat('%S=%S', $token, 'is URI safe'); }
/** * {@inheritdoc} */ public function generateToken() { return substr(parent::generateToken(), 0, 8); }
/** * @ORM\PrePersist */ public function prePersist() { $tokenGenerator = new UriSafeTokenGenerator(new SecureRandom()); $this->setUnsubscribeToken($tokenGenerator->generateToken()); $this->setCreatedAt(new \DateTime()); }