<?php
require_once '../Container/ADODB.php';
require_once '../PHPStopFlood.php';
require_once 'adodb.inc.php';
require_once 'PHPUnit/Framework/TestCase.php';
/**
* PHPStopFlood_Container_File test case.
*/
class PHPStopFlood_Container_ADODB_Test extends PHPUnit_Framework_TestCase {
/**
* @var PHPStopFlood_Container_MySQL
*/
private $_container;
private $_testData = array ("testkey" => "testvalue", "testkey2" => 20);
/**
* Prepares the environment before running a test.
*/
protected function setUp() {
parent::setUp();
$dsn = 'mysql://hide@address.com/test';
$db = NewADOConnection($dsn);
$this->_container = new PHPStopFlood_Container_ADODB(array ("db_object" => $db, "lifetime" => 1));
}
/**
* Cleans up the environment after running a test.
*/
protected function tearDown() {
$this->_container = null;
parent::tearDown();
}
public function testReadWrite() {
$this->_container->write("Test", $this->_testData);
$this->assertEquals($this->_testData, $this->_container->read("Test"));
}
public function testGC() {
$this->_container->gc(1);
$this->assertEquals($this->_testData, $this->_container->read("Test"));
sleep(2);
$this->_container->gc(1);
$this->assertEquals(array (), $this->_container->read("Test"));
}
}