mirror of
https://github.com/mrclay/minify.git
synced 2025-08-12 09:05:08 +02:00
Unit tests for Cache/File.php and Cache/Memcache.php
More consistent file naming
This commit is contained in:
@@ -91,7 +91,6 @@ function test_Minify()
|
||||
|
||||
// Test minifying CSS and responding with Etag/Last-Modified
|
||||
|
||||
// needed to expose E_STRICT warning in Cache_Lite_File
|
||||
Minify::setCache();
|
||||
|
||||
// don't allow conditional headers
|
||||
|
30
min_extras/unit_tests/test_Minify_Cache_File.php
Normal file
30
min_extras/unit_tests/test_Minify_Cache_File.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
require_once '_inc.php';
|
||||
|
||||
require_once 'Minify/Cache/File.php';
|
||||
|
||||
function test_Minify_Cache_File()
|
||||
{
|
||||
$data = str_repeat(md5('testing'), 160);
|
||||
$id = 'Minify_test_cache';
|
||||
$prefix = 'Minify_Cache_File : ';
|
||||
|
||||
$cache = new Minify_Cache_File();
|
||||
|
||||
assertTrue(true === $cache->store($id, $data), $prefix . 'store');
|
||||
|
||||
assertTrue(strlen($data) === $cache->getSize($id), $prefix . 'getSize');
|
||||
|
||||
assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid');
|
||||
|
||||
ob_start();
|
||||
$cache->display($id);
|
||||
$displayed = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
assertTrue($data === $displayed, $prefix . 'display');
|
||||
|
||||
assertTrue($data === $cache->fetch($id), $prefix . 'fetch');
|
||||
}
|
||||
|
||||
test_Minify_Cache_File();
|
38
min_extras/unit_tests/test_Minify_Cache_Memcache.php
Normal file
38
min_extras/unit_tests/test_Minify_Cache_Memcache.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
require_once '_inc.php';
|
||||
|
||||
require_once 'Minify/Cache/Memcache.php';
|
||||
|
||||
function test_Minify_Cache_Memcache()
|
||||
{
|
||||
$prefix = 'Minify_Cache_Memcache : ';
|
||||
if (! function_exists('memcache_set')) {
|
||||
return;
|
||||
}
|
||||
$mc = new Memcache;
|
||||
if (! @$mc->connect('localhost', 11211)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = str_repeat(md5('testing'), 160);
|
||||
$id = 'Minify_test_cache';
|
||||
|
||||
$cache = new Minify_Cache_Memcache($mc);
|
||||
|
||||
assertTrue(true === $cache->store($id, $data), $prefix . 'store');
|
||||
|
||||
assertTrue(strlen($data) === $cache->getSize($id), $prefix . 'getSize');
|
||||
|
||||
assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid');
|
||||
|
||||
ob_start();
|
||||
$cache->display($id);
|
||||
$displayed = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
assertTrue($data === $displayed, $prefix . 'display');
|
||||
|
||||
assertTrue($data === $cache->fetch($id), $prefix . 'fetch');
|
||||
}
|
||||
|
||||
test_Minify_Cache_Memcache();
|
@@ -1,10 +1,13 @@
|
||||
<?php
|
||||
|
||||
require 'test_Minify.php';
|
||||
require 'test_Javascript.php';
|
||||
require 'test_CSS.php';
|
||||
require 'test_Lines.php';
|
||||
require 'test_HTML.php';
|
||||
require 'test_Minify_Build.php';
|
||||
require 'test_Minify_Cache_File.php';
|
||||
require 'test_Minify_Cache_Memcache.php';
|
||||
require 'test_Minify_CSS.php';
|
||||
require 'test_Minify_CSS_Linearizer.php';
|
||||
require 'test_Minify_HTML.php';
|
||||
require 'test_Minify_Javascript.php';
|
||||
require 'test_Minify_Lines.php';
|
||||
require 'test_HTTP_Encoder.php';
|
||||
require 'test_HTTP_ConditionalGet.php';
|
||||
|
Reference in New Issue
Block a user