1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-19 04:11:20 +02:00

port MinifyBuildTest to phpunit

This commit is contained in:
Elan Ruusamäe
2015-11-18 17:23:30 +02:00
committed by Steve Clay
parent 68f011d73f
commit a856756705
3 changed files with 30 additions and 36 deletions

View File

@@ -1,35 +0,0 @@
<?php
require_once '_inc.php';
function test_Minify_CommentPreserver()
{
global $thisDir;
$inOut = array(
'/*!*/' => "\n/*!*/\n"
,'/*!*/a' => "\n/*!*/\n1A"
,'a/*!*//*!*/b' => "2A\n/*!*/\n\n/*!*/\n3B"
,'a/*!*/b/*!*/' => "4A\n/*!*/\n5B\n/*!*/\n"
);
foreach ($inOut as $in => $expected) {
$actual = Minify_CommentPreserver::process($in, '_test_MCP_processor');
$passed = assertTrue($expected === $actual, 'Minify_CommentPreserver');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\n---Output: " .countBytes($actual). " bytes\n\n{$actual}\n\n";
if (!$passed) {
echo "---Expected: " .countBytes($expected). " bytes\n\n{$expected}\n\n\n";
}
}
}
}
function _test_MCP_processor($content, $options = array())
{
static $callCount = 0;
++$callCount;
return $callCount . strtoupper($content);
}
test_Minify_CommentPreserver();

View File

@@ -11,7 +11,6 @@ require 'test_Minify_CSS.php';
require 'test_Minify_CSS_UriRewriter.php';
require 'test_Minify_ClosureCompiler.php';
require 'test_Minify_YuiCSS.php';
require 'test_Minify_CommentPreserver.php';
require 'test_Minify_HTML.php';
require 'test_Minify_ImportProcessor.php';
require 'test_Minify_Lines.php';

View File

@@ -0,0 +1,30 @@
<?php
class MinifyBuildTest extends TestCase
{
public function test()
{
$inOut = array(
'/*!*/' => "\n/*!*/\n",
'/*!*/a' => "\n/*!*/\n1A",
'a/*!*//*!*/b' => "2A\n/*!*/\n\n/*!*/\n3B",
'a/*!*/b/*!*/' => "4A\n/*!*/\n5B\n/*!*/\n",
);
$processor = array(__CLASS__, '_test_MCP_processor');
foreach ($inOut as $in => $expected) {
$actual = Minify_CommentPreserver::process($in, $processor);
$this->assertSame($expected, $actual, 'Minify_CommentPreserver');
}
}
/**
* @internal
*/
public static function _test_MCP_processor($content, $options = array())
{
static $callCount = 0;
++$callCount;
return $callCount . strtoupper($content);
}
}