mirror of
https://github.com/mrclay/minify.git
synced 2025-08-07 06:36:29 +02:00
Test fixes
This commit is contained in:
@@ -232,7 +232,7 @@ class App extends Container
|
||||
}
|
||||
|
||||
// check for URI versioning
|
||||
if ($env->get('v') !== null || preg_match('/&\\d/', $app->env->server('QUERY_STRING'))) {
|
||||
if ($env->get('v') !== null || preg_match('/&\\d/', $app->env->server('QUERY_STRING') ?? '')) {
|
||||
$ret['maxAge'] = 31536000;
|
||||
}
|
||||
|
||||
|
@@ -188,7 +188,7 @@ class Minify_ClosureCompiler
|
||||
*/
|
||||
protected function checkTempdir($tempDir)
|
||||
{
|
||||
if (!is_dir($tempDir)) {
|
||||
if ($tempDir === null || !is_dir($tempDir)) {
|
||||
throw new Minify_ClosureCompiler_Exception('$tempDir(' . $tempDir . ') is not a valid direcotry.');
|
||||
}
|
||||
if (!is_writable($tempDir)) {
|
||||
|
@@ -156,8 +156,8 @@ class Minify_ScssCssSource extends Minify_Source
|
||||
$elapsed = round((microtime(true) - $start), 4);
|
||||
|
||||
$v = Version::VERSION;
|
||||
$ts = date('r', $start);
|
||||
$css = "/* compiled by scssphp $v on $ts (${elapsed}s) */\n\n" . $css;
|
||||
$ts = date('r', (int) $start);
|
||||
$css = "/* compiled by scssphp $v on $ts ({$elapsed}s) */\n\n" . $css;
|
||||
|
||||
$imports = $scss->getParsedFiles();
|
||||
|
||||
|
@@ -113,10 +113,12 @@ class HTTPEncoderTest extends TestCase
|
||||
);
|
||||
|
||||
foreach ($encodingTests as $test) {
|
||||
$e = new HTTP_Encoder(array(
|
||||
$e = new HTTP_Encoder(
|
||||
array(
|
||||
'content' => $variedContent,
|
||||
'method' => $test['method'],
|
||||
));
|
||||
)
|
||||
);
|
||||
$e->encode(9);
|
||||
$ret = $this->countBytes($e->getContent());
|
||||
|
||||
@@ -153,7 +155,7 @@ function _gzdecode($data)
|
||||
}
|
||||
|
||||
// http://www.php.net/manual/en/function.gzdecode.php#82930
|
||||
function _phpman_gzdecode($data, &$filename='', &$error='', $maxlength=null)
|
||||
function _phpman_gzdecode($data, &$filename = '', &$error = '', $maxlength = 0)
|
||||
{
|
||||
$mbIntEnc = null;
|
||||
$hasMbOverload = (function_exists('mb_strlen')
|
||||
|
@@ -6,7 +6,9 @@ use Minify_HTML_Helper;
|
||||
|
||||
class LessSourceTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
public string $realDocRoot;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->realDocRoot = $_SERVER['DOCUMENT_ROOT'];
|
||||
$_SERVER['DOCUMENT_ROOT'] = self::$document_root;
|
||||
|
@@ -6,7 +6,7 @@ use Minify_CSS_UriRewriter;
|
||||
|
||||
class MinifyCSSUriRewriterTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
Minify_CSS_UriRewriter::$debugText = '';
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ use Minify_Cache_APC;
|
||||
|
||||
class MinifyCacheAPCTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
if (!function_exists('apc_store')) {
|
||||
$this->markTestSkipped("To test this component, install APC extension");
|
||||
|
@@ -6,7 +6,7 @@ use Minify_Cache_APCu;
|
||||
|
||||
class MinifyCacheAPCuTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
if (!function_exists('apcu_store')) {
|
||||
$this->markTestSkipped("To test this component, install APCu extension");
|
||||
|
@@ -10,7 +10,7 @@ class MinifyCacheMemcacheTest extends TestCase
|
||||
/** @var Memcache */
|
||||
private $mc;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
if (!function_exists('memcache_set')) {
|
||||
$this->markTestSkipped("To test this component, install memcache in PHP");
|
||||
|
@@ -6,7 +6,7 @@ use Minify_Cache_WinCache;
|
||||
|
||||
class MinifyCacheWinCacheTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
if (!function_exists('wincache_ucache_info')) {
|
||||
$this->markTestSkipped("To test this component, install WinCache extension");
|
||||
|
@@ -6,7 +6,7 @@ use Minify_Cache_ZendPlatform;
|
||||
|
||||
class MinifyCacheZendPlatformTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
if (!function_exists('output_cache_put')) {
|
||||
// FIXME: be specific what to actually install
|
||||
|
@@ -7,7 +7,7 @@ use Minify_ClosureCompiler;
|
||||
|
||||
class MinifyClosureCompilerTest extends TestCase
|
||||
{
|
||||
public static function setupBeforeClass()
|
||||
public static function setupBeforeClass(): void
|
||||
{
|
||||
parent::setupBeforeClass();
|
||||
Minify_ClosureCompiler::$isDebug = true;
|
||||
|
@@ -9,14 +9,14 @@ class MinifyHTMLHelperTest extends TestCase
|
||||
{
|
||||
private $realDocRoot;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->realDocRoot = $_SERVER['DOCUMENT_ROOT'];
|
||||
$_SERVER['DOCUMENT_ROOT'] = self::$document_root;
|
||||
}
|
||||
|
||||
// TODO: this is probably not needed if backupGlobals is enabled?
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
$_SERVER['DOCUMENT_ROOT'] = $this->realDocRoot;
|
||||
}
|
||||
@@ -43,13 +43,16 @@ class MinifyHTMLHelperTest extends TestCase
|
||||
$this->assertEquals($expected, $actual, 'non-existent group & debug');
|
||||
|
||||
$expected = "/myApp/min/?g=css&{$maxTime}";
|
||||
$actual = Minify_HTML_Helper::getUri('css', array(
|
||||
$actual = Minify_HTML_Helper::getUri(
|
||||
'css',
|
||||
array(
|
||||
'rewriteWorks' => false
|
||||
,
|
||||
'minAppUri' => '/myApp/min/'
|
||||
,
|
||||
'groupsConfigFile' => self::$test_files . '/htmlHelper_groupsConfig.php'
|
||||
));
|
||||
)
|
||||
);
|
||||
$this->assertEquals($expected, $actual, 'existing group');
|
||||
|
||||
|
||||
@@ -58,25 +61,32 @@ class MinifyHTMLHelperTest extends TestCase
|
||||
require_once $utilsFile;
|
||||
|
||||
$fiveSecondsAgo = $_SERVER['REQUEST_TIME'] - 5;
|
||||
$obj = new Minify_Source(array(
|
||||
$obj = new Minify_Source(
|
||||
array(
|
||||
'id' => '1',
|
||||
'content' => '1',
|
||||
'lastModified' => $fiveSecondsAgo,
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$output = Minify_mtime(array($uri1, $uri2, $obj));
|
||||
$this->assertEquals($fiveSecondsAgo, $output, 'utils.php : Minify_mtime w/ files & obj');
|
||||
|
||||
$obj = new Minify_Source(array(
|
||||
$obj = new Minify_Source(
|
||||
array(
|
||||
'id' => '2',
|
||||
'content' => '2',
|
||||
'lastModified' => strtotime('2000-01-01'),
|
||||
));
|
||||
$output = Minify_mtime(array(
|
||||
)
|
||||
);
|
||||
$output = Minify_mtime(
|
||||
array(
|
||||
$obj
|
||||
,
|
||||
'css'
|
||||
), self::$test_files . '/htmlHelper_groupsConfig.php');
|
||||
),
|
||||
self::$test_files . '/htmlHelper_groupsConfig.php'
|
||||
);
|
||||
$this->assertEquals($maxTime, $output, 'utils.php : Minify_mtime w/ obj & group');
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ use Minify_NailgunClosureCompiler;
|
||||
|
||||
class MinifyNailgunClosureCompilerTest extends TestCase
|
||||
{
|
||||
public static function setupBeforeClass()
|
||||
public static function setupBeforeClass(): void
|
||||
{
|
||||
parent::setupBeforeClass();
|
||||
Minify_ClosureCompiler::$isDebug = true;
|
||||
|
@@ -7,7 +7,7 @@ use Minify_YUICompressor;
|
||||
|
||||
class MinifyYuiCSSTest extends TestCase
|
||||
{
|
||||
public static function setupBeforeClass()
|
||||
public static function setupBeforeClass(): void
|
||||
{
|
||||
parent::setupBeforeClass();
|
||||
|
||||
@@ -18,7 +18,7 @@ class MinifyYuiCSSTest extends TestCase
|
||||
Minify_YUICompressor::$tempDir = sys_get_temp_dir();
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->assertHasJar();
|
||||
}
|
||||
|
@@ -6,7 +6,9 @@ use Minify_HTML_Helper;
|
||||
|
||||
class ScssSourceTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
public string $realDocRoot;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->realDocRoot = $_SERVER['DOCUMENT_ROOT'];
|
||||
$_SERVER['DOCUMENT_ROOT'] = self::$document_root;
|
||||
|
@@ -11,7 +11,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
|
||||
/** @var string */
|
||||
protected static $test_files;
|
||||
|
||||
public static function setupBeforeClass()
|
||||
public static function setupBeforeClass(): void
|
||||
{
|
||||
self::$document_root = __DIR__;
|
||||
self::$test_files = __DIR__ . '/_test_files';
|
||||
|
Reference in New Issue
Block a user