Update Tests to supports namespaces
This commit is contained in:
74
Tests/RatelimitfileTest.php
Normal file
74
Tests/RatelimitfileTest.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/** DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
|
||||
namespace Domframework\Tests;
|
||||
|
||||
/** Test the ratelimitfile.php file */
|
||||
class ratelimitfileTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_ratelimitfile0 ()
|
||||
{
|
||||
exec ("rm -rf /tmp/testDFWratelimit");
|
||||
}
|
||||
|
||||
public function test_ratelimitfile1 ()
|
||||
{
|
||||
// Create one non ratelimited entry
|
||||
$ratelimitfile = new ratelimitfile ();
|
||||
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
||||
$res = $ratelimitfile->set ("TOTO");
|
||||
$this->assertSame (true, $res);
|
||||
}
|
||||
|
||||
public function test_ratelimitfile2 ()
|
||||
{
|
||||
// Too much entries
|
||||
$ratelimitfile = new ratelimitfile ();
|
||||
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
||||
$ratelimitfile->set ("TOTO");
|
||||
$ratelimitfile->set ("TOTO");
|
||||
$ratelimitfile->set ("TOTO");
|
||||
$ratelimitfile->set ("TOTO");
|
||||
$ratelimitfile->set ("TOTO");
|
||||
$ratelimitfile->set ("TOTO");
|
||||
$ratelimitfile->set ("TOTO");
|
||||
$ratelimitfile->set ("TOTO");
|
||||
$ratelimitfile->set ("TOTO");
|
||||
$res = $ratelimitfile->set ("TOTO");
|
||||
$this->assertSame (false, $res);
|
||||
}
|
||||
|
||||
public function test_ratelimitfile3 ()
|
||||
{
|
||||
// Del the ratelimited entry
|
||||
$ratelimitfile = new ratelimitfile ();
|
||||
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
||||
$res = $ratelimitfile->del ("TOTO");
|
||||
$this->assertSame (true, $res);
|
||||
}
|
||||
|
||||
public function test_ratelimitfile4 ()
|
||||
{
|
||||
// Create one non ratelimited entry
|
||||
$ratelimitfile = new ratelimitfile ();
|
||||
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
||||
$res = $ratelimitfile->set ("TOTO");
|
||||
$this->assertSame (true, $res);
|
||||
}
|
||||
|
||||
public function test_ratelimitfile5 ()
|
||||
{
|
||||
// Clean expired entries
|
||||
sleep (2);
|
||||
$ratelimitfile = new ratelimitfile ();
|
||||
$ratelimitfile->unittime = 1;
|
||||
$ratelimitfile->storageDir = "/tmp/testDFWratelimit";
|
||||
$ratelimitfile->clean ();
|
||||
$res = count (glob ("/tmp/testDFWratelimit/*"));
|
||||
$this->assertSame (0, $res);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user