mirror of
https://github.com/mrclay/minify.git
synced 2025-01-17 21:28:14 +01:00
port MinifyCSSUriRewriterTest to phpunit
This commit is contained in:
parent
6e7767aa3e
commit
3a9687ad4e
@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once '_inc.php';
|
||||
|
||||
function test_Minify_CSS_UriRewriter()
|
||||
{
|
||||
global $thisDir;
|
||||
|
||||
Minify_CSS_UriRewriter::$debugText = '';
|
||||
$in = file_get_contents($thisDir . '/_test_files/css_uriRewriter/in.css');
|
||||
$expected = file_get_contents($thisDir . '/_test_files/css_uriRewriter/exp.css');
|
||||
$actual = Minify_CSS_UriRewriter::rewrite(
|
||||
$in
|
||||
,$thisDir . '/_test_files/css_uriRewriter' // currentDir
|
||||
,$thisDir // use DOCUMENT_ROOT = '/full/path/to/min_unit_tests'
|
||||
);
|
||||
|
||||
$passed = assertTrue($expected === $actual, 'Minify_CSS_UriRewriter : rewrite');
|
||||
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
|
||||
echo "\n---Input:\n\n{$in}\n";
|
||||
echo "\n---Output: " .countBytes($actual). " bytes\n\n{$actual}\n\n";
|
||||
if (!$passed) {
|
||||
echo "---Expected: " .countBytes($expected). " bytes\n\n{$expected}\n\n\n";
|
||||
}
|
||||
|
||||
// show debugging only when test run directly
|
||||
echo "--- Minify_CSS_UriRewriter::\$debugText\n\n"
|
||||
, Minify_CSS_UriRewriter::$debugText;
|
||||
}
|
||||
|
||||
|
||||
Minify_CSS_UriRewriter::$debugText = '';
|
||||
$in = file_get_contents($thisDir . '/_test_files/css_uriRewriter/in.css');
|
||||
$expected = file_get_contents($thisDir . '/_test_files/css_uriRewriter/exp_prepend.css');
|
||||
$actual = Minify_CSS_UriRewriter::prepend($in, 'http://cnd.com/A/B/');
|
||||
|
||||
$passed = assertTrue($expected === $actual, 'Minify_CSS_UriRewriter : prepend1');
|
||||
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
|
||||
echo "\n---Input:\n\n{$in}\n";
|
||||
echo "\n---Output: " .countBytes($actual). " bytes\n\n{$actual}\n\n";
|
||||
if (!$passed) {
|
||||
echo "---Expected: " .countBytes($expected). " bytes\n\n{$expected}\n\n\n";
|
||||
}
|
||||
|
||||
// show debugging only when test run directly
|
||||
echo "--- Minify_CSS_UriRewriter::\$debugText\n\n"
|
||||
, Minify_CSS_UriRewriter::$debugText;
|
||||
}
|
||||
|
||||
|
||||
Minify_CSS_UriRewriter::$debugText = '';
|
||||
$in = file_get_contents($thisDir . '/_test_files/css_uriRewriter/in.css');
|
||||
$expected = file_get_contents($thisDir . '/_test_files/css_uriRewriter/exp_prepend2.css');
|
||||
$actual = Minify_CSS_UriRewriter::prepend($in, '//cnd.com/A/B/');
|
||||
|
||||
$passed = assertTrue($expected === $actual, 'Minify_CSS_UriRewriter : prepend2');
|
||||
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
|
||||
echo "\n---Input:\n\n{$in}\n";
|
||||
echo "\n---Output: " .countBytes($actual). " bytes\n\n{$actual}\n\n";
|
||||
if (!$passed) {
|
||||
echo "---Expected: " .countBytes($expected). " bytes\n\n{$expected}\n\n\n";
|
||||
}
|
||||
|
||||
// show debugging only when test run directly
|
||||
echo "--- Minify_CSS_UriRewriter::\$debugText\n\n"
|
||||
, Minify_CSS_UriRewriter::$debugText;
|
||||
}
|
||||
|
||||
|
||||
Minify_CSS_UriRewriter::$debugText = '';
|
||||
$in = '../../../../assets/skins/sam/sprite.png';
|
||||
$exp = '/yui/assets/skins/sam/sprite.png';
|
||||
$actual = Minify_CSS_UriRewriter::rewriteRelative(
|
||||
$in
|
||||
,'sf_root_dir\web\yui\menu\assets\skins\sam'
|
||||
,'sf_root_dir\web'
|
||||
);
|
||||
|
||||
$passed = assertTrue($exp === $actual, 'Minify_CSS_UriRewriter : Issue 99');
|
||||
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
|
||||
echo "\n---Input:\n\n{$in}\n";
|
||||
echo "\n---Output: " .countBytes($actual). " bytes\n\n{$actual}\n\n";
|
||||
if (!$passed) {
|
||||
echo "---Expected: " .countBytes($exp). " bytes\n\n{$exp}\n\n\n";
|
||||
}
|
||||
|
||||
// show debugging only when test run directly
|
||||
echo "--- Minify_CSS_UriRewriter::\$debugText\n\n"
|
||||
, Minify_CSS_UriRewriter::$debugText;
|
||||
}
|
||||
}
|
||||
|
||||
test_Minify_CSS_UriRewriter();
|
@ -2,7 +2,6 @@
|
||||
|
||||
require 'test_Minify.php';
|
||||
require 'test_Minify_CSS.php';
|
||||
require 'test_Minify_CSS_UriRewriter.php';
|
||||
require 'test_Minify_Lines.php';
|
||||
require 'test_HTTP_ConditionalGet.php';
|
||||
require 'test_environment.php';
|
||||
|
53
tests/MinifyCSSUriRewriterTest.php
Normal file
53
tests/MinifyCSSUriRewriterTest.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
class MinifyCSSUriRewriterTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
Minify_CSS_UriRewriter::$debugText = '';
|
||||
}
|
||||
|
||||
public function test1()
|
||||
{
|
||||
$in = file_get_contents(self::$test_files . '/css_uriRewriter/in.css');
|
||||
$expected = file_get_contents(self::$test_files . '/css_uriRewriter/exp.css');
|
||||
$actual = Minify_CSS_UriRewriter::rewrite(
|
||||
$in
|
||||
, self::$test_files . '/css_uriRewriter' // currentDir
|
||||
, self::$document_root // use DOCUMENT_ROOT = '/full/path/to/min_unit_tests'
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $actual, 'rewrite, debug: ' . Minify_CSS_UriRewriter::$debugText);
|
||||
}
|
||||
|
||||
public function test2()
|
||||
{
|
||||
$in = file_get_contents(self::$test_files . '/css_uriRewriter/in.css');
|
||||
$expected = file_get_contents(self::$test_files . '/css_uriRewriter/exp_prepend.css');
|
||||
$actual = Minify_CSS_UriRewriter::prepend($in, 'http://cnd.com/A/B/');
|
||||
|
||||
$this->assertEquals($expected, $actual, 'prepend1, debug: ' . Minify_CSS_UriRewriter::$debugText);
|
||||
}
|
||||
|
||||
public function test3()
|
||||
{
|
||||
$in = file_get_contents(self::$test_files . '/css_uriRewriter/in.css');
|
||||
$expected = file_get_contents(self::$test_files . '/css_uriRewriter/exp_prepend2.css');
|
||||
$actual = Minify_CSS_UriRewriter::prepend($in, '//cnd.com/A/B/');
|
||||
|
||||
$this->assertEquals($expected, $actual, 'prepend2, debug: ' . Minify_CSS_UriRewriter::$debugText);
|
||||
}
|
||||
|
||||
public function test4()
|
||||
{
|
||||
$in = '../../../../assets/skins/sam/sprite.png';
|
||||
$exp = '/yui/assets/skins/sam/sprite.png';
|
||||
$actual = Minify_CSS_UriRewriter::rewriteRelative(
|
||||
$in
|
||||
, 'sf_root_dir\web\yui\menu\assets\skins\sam'
|
||||
, 'sf_root_dir\web'
|
||||
);
|
||||
|
||||
$this->assertEquals($exp, $actual, 'Issue 99, debug: ' . Minify_CSS_UriRewriter::$debugText);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user