Test of cachefile should be done in /tmp

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1654 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-08-01 12:52:43 +00:00
parent 45b70602a7
commit c6587aeb11

View File

@@ -10,6 +10,7 @@ class test_cachefile extends PHPUnit_Framework_TestCase
{ {
// Removing the cache file if it previously exists // Removing the cache file if it previously exists
$c = new cachefile (); $c = new cachefile ();
$c->directory = "/tmp/cache";
$res = $c->delete ("id"); $res = $c->delete ("id");
} }
@@ -17,6 +18,7 @@ class test_cachefile extends PHPUnit_Framework_TestCase
public function testRead1 () public function testRead1 ()
{ {
$c = new cachefile (); $c = new cachefile ();
$c->directory = "/tmp/cache";
$res = $c->read ("id"); $res = $c->read ("id");
$this->assertFalse ($res); $this->assertFalse ($res);
} }
@@ -25,6 +27,7 @@ class test_cachefile extends PHPUnit_Framework_TestCase
public function testWrite1 () public function testWrite1 ()
{ {
$c = new cachefile (); $c = new cachefile ();
$c->directory = "/tmp/cache";
$res = $c->write ("id","DATA_TO_STORE", 3); $res = $c->write ("id","DATA_TO_STORE", 3);
$this->assertTrue ($res); $this->assertTrue ($res);
} }
@@ -33,6 +36,7 @@ class test_cachefile extends PHPUnit_Framework_TestCase
public function testRead2 () public function testRead2 ()
{ {
$c = new cachefile (); $c = new cachefile ();
$c->directory = "/tmp/cache";
$res = $c->read ("id"); $res = $c->read ("id");
$this->assertEquals ("DATA_TO_STORE", $res); $this->assertEquals ("DATA_TO_STORE", $res);
} }
@@ -47,6 +51,7 @@ class test_cachefile extends PHPUnit_Framework_TestCase
public function testRead3 () public function testRead3 ()
{ {
$c = new cachefile (); $c = new cachefile ();
$c->directory = "/tmp/cache";
$res = $c->read ("id"); $res = $c->read ("id");
$this->assertFalse ($res); $this->assertFalse ($res);
} }
@@ -55,6 +60,7 @@ class test_cachefile extends PHPUnit_Framework_TestCase
public function testWrite2 () public function testWrite2 ()
{ {
$c = new cachefile (); $c = new cachefile ();
$c->directory = "/tmp/cache";
$res = $c->write ("id","DATA_TO_STORE", 30); $res = $c->write ("id","DATA_TO_STORE", 30);
$this->assertTrue ($res); $this->assertTrue ($res);
} }
@@ -62,13 +68,14 @@ class test_cachefile extends PHPUnit_Framework_TestCase
// Create stale lock // Create stale lock
public function testLock1 () public function testLock1 ()
{ {
touch ("cache/".sha1 ("id").".lock"); touch ("/tmp/cache/".sha1 ("id").".lock");
} }
// Previous cache in time file but lock : return content after lock timeout // Previous cache in time file but lock : return content after lock timeout
public function testRead4 () public function testRead4 ()
{ {
$c = new cachefile (); $c = new cachefile ();
$c->directory = "/tmp/cache";
$res = $c->read ("id"); $res = $c->read ("id");
$this->assertEquals ("DATA_TO_STORE", $res); $this->assertEquals ("DATA_TO_STORE", $res);
} }
@@ -76,6 +83,7 @@ class test_cachefile extends PHPUnit_Framework_TestCase
public function testDel1 () public function testDel1 ()
{ {
$c = new cachefile (); $c = new cachefile ();
$c->directory = "/tmp/cache";
$res = $c->delete ("id"); $res = $c->delete ("id");
} }
} }