mirror of
https://github.com/mrclay/minify.git
synced 2025-08-05 13:47:38 +02:00
port MinifyHTMLTest to phpunit
This commit is contained in:
committed by
Steve Clay
parent
16b8296c34
commit
6e7767aa3e
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once '_inc.php';
|
|
||||||
|
|
||||||
function test_HTML()
|
|
||||||
{
|
|
||||||
global $thisDir;
|
|
||||||
|
|
||||||
$src = file_get_contents($thisDir . '/_test_files/html/before.html');
|
|
||||||
$minExpected = file_get_contents($thisDir . '/_test_files/html/before.min.html');
|
|
||||||
|
|
||||||
$time = microtime(true);
|
|
||||||
$minOutput = Minify_HTML::minify($src, array(
|
|
||||||
'cssMinifier' => array('Minify_CSSmin', 'minify')
|
|
||||||
,'jsMinifier' => array('JSMin\\JSMin', 'minify')
|
|
||||||
));
|
|
||||||
$time = microtime(true) - $time;
|
|
||||||
|
|
||||||
$passed = assertTrue($minExpected === $minOutput, 'Minify_HTML');
|
|
||||||
|
|
||||||
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
|
|
||||||
if ($passed) {
|
|
||||||
echo "\n---Source: ", countBytes($src), " bytes\n"
|
|
||||||
, "---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
|
|
||||||
} else {
|
|
||||||
echo "\n---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n"
|
|
||||||
, "---Expected: ", countBytes($minExpected), " bytes\n\n{$minExpected}\n\n"
|
|
||||||
, "---Source: ", countBytes($src), " bytes\n\n{$src}\n\n\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$src = file_get_contents($thisDir . '/_test_files/html/before2.html');
|
|
||||||
$minExpected = file_get_contents($thisDir . '/_test_files/html/before2.min.html');
|
|
||||||
|
|
||||||
$time = microtime(true);
|
|
||||||
$minOutput = Minify_HTML::minify($src, array(
|
|
||||||
'cssMinifier' => array('Minify_CSSmin', 'minify')
|
|
||||||
,'jsMinifier' => array('JSMin\\JSMin', 'minify')
|
|
||||||
));
|
|
||||||
$time = microtime(true) - $time;
|
|
||||||
|
|
||||||
$passed = assertTrue($minExpected === $minOutput, 'Minify_HTML');
|
|
||||||
|
|
||||||
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
|
|
||||||
if ($passed) {
|
|
||||||
echo "\n---Source: ", countBytes($src), " bytes\n"
|
|
||||||
, "---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
|
|
||||||
} else {
|
|
||||||
echo "\n---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n"
|
|
||||||
, "---Expected: ", countBytes($minExpected), " bytes\n\n{$minExpected}\n\n"
|
|
||||||
, "---Source: ", countBytes($src), " bytes\n\n{$src}\n\n\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
test_HTML();
|
|
@@ -3,7 +3,6 @@
|
|||||||
require 'test_Minify.php';
|
require 'test_Minify.php';
|
||||||
require 'test_Minify_CSS.php';
|
require 'test_Minify_CSS.php';
|
||||||
require 'test_Minify_CSS_UriRewriter.php';
|
require 'test_Minify_CSS_UriRewriter.php';
|
||||||
require 'test_Minify_HTML.php';
|
|
||||||
require 'test_Minify_Lines.php';
|
require 'test_Minify_Lines.php';
|
||||||
require 'test_HTTP_ConditionalGet.php';
|
require 'test_HTTP_ConditionalGet.php';
|
||||||
require 'test_environment.php';
|
require 'test_environment.php';
|
||||||
|
30
tests/MinifyHTMLTest.php
Normal file
30
tests/MinifyHTMLTest.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class MinifyHTMLTest extends TestCase
|
||||||
|
{
|
||||||
|
public function test1()
|
||||||
|
{
|
||||||
|
$src = file_get_contents(self::$test_files . '/html/before.html');
|
||||||
|
$minExpected = file_get_contents(self::$test_files . '/html/before.min.html');
|
||||||
|
|
||||||
|
$minOutput = Minify_HTML::minify($src, array(
|
||||||
|
'cssMinifier' => array('Minify_CSSmin', 'minify'),
|
||||||
|
'jsMinifier' => array('JSMin\\JSMin', 'minify'),
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertEquals($minExpected, $minOutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test2()
|
||||||
|
{
|
||||||
|
$src = file_get_contents(self::$test_files . '/html/before2.html');
|
||||||
|
$minExpected = file_get_contents(self::$test_files . '/html/before2.min.html');
|
||||||
|
|
||||||
|
$minOutput = Minify_HTML::minify($src, array(
|
||||||
|
'cssMinifier' => array('Minify_CSSmin', 'minify'),
|
||||||
|
'jsMinifier' => array('JSMin\\JSMin', 'minify'),
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertEquals($minExpected, $minOutput);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user