/**
  * @covers TokenManager\TokenManager::clean
  */
 public function testTokenManagerClean()
 {
     $options = array('dir' => $this->tokenDirPath, 'prefix' => '1234', 'minTimeout' => 1, 'maxTimeout' => 1);
     $this->cleanTokenDir($options['dir']);
     $tokenManager = new TokenManager($options);
     $token = $tokenManager->get();
     $tokenFile = $options['dir'] . $options['prefix'] . $token;
     sleep(2);
     $nb = $tokenManager->clean();
     $this->assertEquals(1, $nb);
     $this->assertFalse(file_exists($tokenFile));
 }
Пример #2
0
<?php

require '../vendor/autoload.php';
use TokenManager\TokenManager;
// Setup
$options = array('dir' => './tokens/', 'prefix' => 'token', 'salt' => 'salt', 'hash' => 'sha256', 'maxTimeout' => 120, 'maxTimeout' => 30);
$TokenMgr = new TokenManager($options);
// 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