mirror of
https://github.com/mrclay/minify.git
synced 2025-08-07 22:56:33 +02:00
move common cache test assertion to TestCase
This commit is contained in:
committed by
Steve Clay
parent
554542401f
commit
f71dd4c79f
@@ -22,19 +22,4 @@ class MinifyCacheFileTest extends TestCase
|
|||||||
|
|
||||||
$this->assertTestCache($cache, $id, $data);
|
$this->assertTestCache($cache, $id, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function assertTestCache(Minify_Cache_File $cache, $id, $data)
|
|
||||||
{
|
|
||||||
$this->assertTrue($cache->store($id, $data), "$id store");
|
|
||||||
$this->assertEquals($cache->getSize($id), $this->countBytes($data), "$id getSize");
|
|
||||||
$this->assertTrue($cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), "$id isValid");
|
|
||||||
|
|
||||||
ob_start();
|
|
||||||
$cache->display($id);
|
|
||||||
$displayed = ob_get_contents();
|
|
||||||
ob_end_clean();
|
|
||||||
|
|
||||||
$this->assertSame($data, $displayed, "$id display");
|
|
||||||
$this->assertEquals($data, $cache->fetch($id), "$id fetch");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -33,4 +33,26 @@ class TestCase extends PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common assertion for cache tests.
|
||||||
|
*
|
||||||
|
* @param Minify_CacheInterface $cache
|
||||||
|
* @param string $id
|
||||||
|
* @param string $data
|
||||||
|
*/
|
||||||
|
protected function assertTestCache(Minify_CacheInterface $cache, $id, $data)
|
||||||
|
{
|
||||||
|
$this->assertTrue($cache->store($id, $data), "$id store");
|
||||||
|
$this->assertEquals($cache->getSize($id), $this->countBytes($data), "$id getSize");
|
||||||
|
$this->assertTrue($cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), "$id isValid");
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
$cache->display($id);
|
||||||
|
$displayed = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
|
||||||
|
$this->assertSame($data, $displayed, "$id display");
|
||||||
|
$this->assertEquals($data, $cache->fetch($id), "$id fetch");
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user