git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5231 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
64 lines
1.4 KiB
PHP
64 lines
1.4 KiB
PHP
<?php
|
|
/** DomFramework - Tests
|
|
* @package domframework
|
|
* @author Dominique Fournier <dominique@fournier38.fr>
|
|
*/
|
|
|
|
/** Test the csrf.php file */
|
|
class test_csrf extends PHPUnit_Framework_TestCase
|
|
{
|
|
public function test_csrf1 ()
|
|
{
|
|
$csrf = new csrf ();
|
|
$res = $csrf->createToken ();
|
|
$this->assertSame (30, strlen ($res));
|
|
}
|
|
|
|
public function test_csrf2 ()
|
|
{
|
|
$csrf = new csrf ();
|
|
$res = $csrf->createToken ();
|
|
$this->assertSame (
|
|
strspn ($res,
|
|
"abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ") , strlen ($res));
|
|
}
|
|
|
|
public function test_csrf3 ()
|
|
{
|
|
$csrf = new csrf ();
|
|
$this->setExpectedException ("Exception");
|
|
$res = $csrf->checkToken ("NOT VALID TOKEN");
|
|
}
|
|
|
|
public function test_csrf4 ()
|
|
{
|
|
$csrf = new csrf ();
|
|
$token = $csrf->createToken ();
|
|
$res = $csrf->checkToken ($token);
|
|
$this->assertSame (true, $res);
|
|
}
|
|
|
|
public function test_csrf5 ()
|
|
{
|
|
$csrf = new csrf ();
|
|
$token = $csrf->createToken ();
|
|
$res = $csrf->extendToken ($token);
|
|
$this->assertSame (true, $res);
|
|
}
|
|
|
|
public function test_csrf6 ()
|
|
{
|
|
$csrf = new csrf ();
|
|
$token = $csrf->createToken ();
|
|
$res = $csrf->getToken ();
|
|
$this->assertSame ($token, $res);
|
|
}
|
|
|
|
public function test_csrf7 ()
|
|
{
|
|
$csrf = new csrf ();
|
|
$res = $csrf->getToken ();
|
|
$this->assertSame (30, strlen ($res));
|
|
}
|
|
}
|