/** * @covers TokenManager\TokenManager::get * @covers TokenManager\TokenManager::create * @covers TokenManager\TokenManager::getExistingValid */ public function testTokenManagerGet() { $options = array('dir' => $this->tokenDirPath, 'prefix' => '1234'); $this->cleanTokenDir($options['dir']); $tokenManager = new TokenManager($options); $token = $tokenManager->get(); $this->assertTrue(is_string($token), $tokenManager->getLastError()); $tokenFile = $options['dir'] . $options['prefix'] . $token; $this->assertTrue(file_exists($tokenFile)); $token2 = $tokenManager->get(); $this->assertEquals($token2, $token); $this->cleanTokenDir($options['dir']); }
// Get token $token = $TokenMgr->get(); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>php-token-manager : get</title> <meta name="description" content="php-token-manager : get"> <meta name="author" content="Gregory Brousse"> </head> <body> <a href="./usage-verify.php?token=<?php echo $token; ?> ">Test with right token</a><br/> <a href="./usage-verify.php?token=123456">Test with wrong token</a><br/> <a href="./usage-verify.php">Test with no token</a><br/> <br/> Last error : <?php echo $TokenMgr->getLastError(); ?> </body> </html>