mirror of
https://github.com/mrclay/minify.git
synced 2025-08-06 06:07:24 +02:00
Collapse "min" into project root and get unit tests working.
Fixes #472
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,4 @@
|
||||
/test
|
||||
/docs
|
||||
/.idea/
|
||||
.DS_Store
|
||||
/vendor/
|
||||
|
2
MIN.txt
2
MIN.txt
@@ -145,7 +145,7 @@ Then create a new file, for example "min.php" in your site root. The contents of
|
||||
this file could look like this:
|
||||
|
||||
<?php
|
||||
$customConfigDirectory = dirname(__FILE__) . '/min-configs';
|
||||
$customConfigDirectory = __DIR__ . '/min-configs';
|
||||
$min_customConfigPaths = array(
|
||||
'base' => $customConfigDirectory . '/config.php',
|
||||
'test' => $customConfigDirectory . '/config-test.php',
|
||||
|
39
README.md
39
README.md
@@ -24,15 +24,29 @@ Unfortunately we can't support the WordPress plugins here.
|
||||
Installation
|
||||
------------
|
||||
|
||||
Place the `/min/` directory as a child of your DOCUMENT_ROOT
|
||||
directory: i.e. you will have: `/home/example/www/min`
|
||||
Installation requires PHP 5.3+, SSH access, and access to tools like `git` and `composer` or the privileges to install them.
|
||||
|
||||
You can see verify that it is working by visiting these two URLs:
|
||||
- http://example.org/min/?f=min/quick-test.js
|
||||
- http://example.org/min/?f=min/quick-test.css
|
||||
```bash
|
||||
cd /path/to/public_html
|
||||
git clone https://github.com/mrclay/minify.git min
|
||||
cd min
|
||||
composer install
|
||||
```
|
||||
|
||||
What this does:
|
||||
|
||||
1. Inside your DOCUMENT_ROOT directory, we clone this repo. Otherwise you may [download](https://github.com/mrclay/minify/archive/master.zip) and extract the zip file.
|
||||
1. We rename this directory `min`. E.g. You will have something like: `/home/example/public_html/min`
|
||||
1. We `cd` into it and run `composer install` to install the dependencies.
|
||||
|
||||
You can verify that it is working by visiting these two URLs:
|
||||
|
||||
* http://example.org/min/?f=min/quick-test.js
|
||||
* http://example.org/min/?f=min/quick-test.css
|
||||
|
||||
If your server supports mod_rewrite, this URL should also work:
|
||||
- http://example.org/min/f=min/quick-test.js
|
||||
|
||||
* http://example.org/min/f=min/quick-test.js
|
||||
|
||||
Configuration & Usage
|
||||
---------------------
|
||||
@@ -54,15 +68,10 @@ Support
|
||||
Unit Testing
|
||||
------------
|
||||
|
||||
1. Place the /min_unit_tests/ directory as a child of your DOCUMENT_ROOT
|
||||
directory: i.e. you will have: /home/example/www/min_unit_tests
|
||||
|
||||
2. To run unit tests, access: http://example.org/min_unit_tests/test_all.php
|
||||
|
||||
(If you wish, the other test_*.php files can be run to test individual
|
||||
components with more verbose output.)
|
||||
|
||||
3. Remove /min_unit_tests/ from your DOCUMENT_ROOT when you are done.
|
||||
1. Open the file `min_unit_tests/_inc.php`.
|
||||
1. Enable the file by commenting out the `die()` statement.
|
||||
1. Access: http://example.org/min/min_unit_tests/test_all.php (If you wish, the other test_*.php files can be run to test individual components with more verbose output.)
|
||||
1. Re-disable the `_inc.php` file when you are done.
|
||||
|
||||
Warnings
|
||||
--------
|
||||
|
@@ -12,13 +12,13 @@ if (0 === strpos($_SERVER["SERVER_SOFTWARE"], 'Apache/')
|
||||
$userDir = DIRECTORY_SEPARATOR . $m[1] . DIRECTORY_SEPARATOR;
|
||||
if (false !== strpos(__FILE__, $userDir)) {
|
||||
$sm = array();
|
||||
$sm["//~{$m[1]}"] = dirname(dirname(__FILE__));
|
||||
$sm["//~{$m[1]}"] = dirname(__DIR__);
|
||||
$array = str_replace('array (', 'array(', var_export($sm, 1));
|
||||
$symlinkOption = "\$min_symlinks = $array;";
|
||||
}
|
||||
}
|
||||
|
||||
require __DIR__ . '/../../bootstrap.php';
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
require __DIR__ . '/../config.php';
|
||||
|
||||
if (! $min_enableBuilder) {
|
||||
@@ -159,7 +159,7 @@ by Minify. E.g. <code>@import "<span class=minRoot>/min/?</span>g=css2";</code><
|
||||
</div><!-- #app -->
|
||||
|
||||
<hr>
|
||||
<p>Need help? Check the <a href="http://code.google.com/p/minify/w/list?can=3">wiki</a>,
|
||||
<p>Need help? Check the <a href="https://github.com/mrclay/minify/tree/master/docs">wiki</a>,
|
||||
or post to the <a class=ext href="http://groups.google.com/group/minify">discussion
|
||||
list</a>.</p>
|
||||
<p><small>Powered by Minify <?php echo Minify::VERSION; ?></small></p>
|
||||
@@ -239,8 +239,8 @@ $server->serve($controller, array(
|
||||
'lastModifiedTime' => max(
|
||||
// regenerate cache if any of these change
|
||||
filemtime(__FILE__),
|
||||
filemtime(dirname(__FILE__) . '/../config.php'),
|
||||
filemtime(dirname(__FILE__) . '/../lib/Minify.php')
|
||||
filemtime(__DIR__ . '/../config.php'),
|
||||
filemtime(__DIR__ . '/../lib/Minify.php')
|
||||
),
|
||||
'minifyAll' => true,
|
||||
'encodeOutput' => $encodeOutput,
|
@@ -5,12 +5,12 @@
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
require __DIR__ . '/../../bootstrap.php';
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
|
||||
$_oc = ini_get('zlib.output_compression');
|
||||
|
||||
// allow access only if builder is enabled
|
||||
require dirname(__FILE__) . '/../config.php';
|
||||
require __DIR__ . '/../config.php';
|
||||
if (! $min_enableBuilder) {
|
||||
header('Location: /');
|
||||
exit;
|
@@ -6,7 +6,7 @@ exit;
|
||||
$_oc = ini_get('zlib.output_compression');
|
||||
|
||||
// allow access only if builder is enabled
|
||||
require dirname(__FILE__) . '/../config.php';
|
||||
require __DIR__ . '/../config.php';
|
||||
if (! $min_enableBuilder) {
|
||||
exit;
|
||||
}
|
@@ -17,7 +17,7 @@
|
||||
"wiki": "https://github.com/mrclay/minify/blob/master/docs"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": ["min/lib/"]
|
||||
"classmap": ["lib/"]
|
||||
},
|
||||
"require": {
|
||||
"ext-pcre": "*",
|
||||
|
2
composer.lock
generated
2
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "523e463e2f705e3389708dffaeeda859",
|
||||
"hash": "de48bc346ef046cc11ddc45358b1887b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "firephp/firephp-core",
|
||||
|
@@ -10,7 +10,7 @@
|
||||
/**
|
||||
* Allow use of the Minify URI Builder app. Only set this to true while you need it.
|
||||
*/
|
||||
$min_enableBuilder = false;
|
||||
$min_enableBuilder = true;
|
||||
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ $min_allowDebugFlag = false;
|
||||
* second line. The third line might work on some Apache servers.
|
||||
*/
|
||||
$min_documentRoot = '';
|
||||
//$min_documentRoot = dirname(dirname(dirname(__FILE__)));
|
||||
//$min_documentRoot = dirname(dirname(__DIR__));
|
||||
//$min_documentRoot = substr(__FILE__, 0, -15);
|
||||
//$min_documentRoot = $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'];
|
||||
|
@@ -7,15 +7,13 @@
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
|
||||
define('MINIFY_MIN_DIR', dirname(__FILE__));
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
// set config path defaults
|
||||
$min_configPaths = array(
|
||||
'base' => MINIFY_MIN_DIR . '/config.php',
|
||||
'test' => MINIFY_MIN_DIR . '/config-test.php',
|
||||
'groups' => MINIFY_MIN_DIR . '/groupsConfig.php',
|
||||
'base' => __DIR__ . '/config.php',
|
||||
'test' => __DIR__ . '/config-test.php',
|
||||
'groups' => __DIR__ . '/groupsConfig.php',
|
||||
);
|
||||
|
||||
// check for custom config paths
|
@@ -84,7 +84,7 @@ class Minify {
|
||||
'encodeLevel' => 9,
|
||||
|
||||
'minifiers' => array(
|
||||
Minify::TYPE_JS => array('JSMin', 'minify'),
|
||||
Minify::TYPE_JS => array('JSMin\\JSMin', 'minify'),
|
||||
Minify::TYPE_CSS => array('Minify_CSS', 'minify'),
|
||||
Minify::TYPE_HTML => array('Minify_HTML', 'minify'),
|
||||
),
|
@@ -53,7 +53,7 @@ class Minify_Controller_Page extends Minify_Controller_Base {
|
||||
// this will be the 2nd argument passed to Minify_HTML::minify()
|
||||
$sourceSpec['minifyOptions'] = array(
|
||||
'cssMinifier' => array('Minify_CSS', 'minify')
|
||||
,'jsMinifier' => array('JSMin', 'minify')
|
||||
,'jsMinifier' => array('JSMin\\JSMin', 'minify')
|
||||
);
|
||||
unset($options['minifyAll']);
|
||||
}
|
@@ -115,7 +115,7 @@ class Minify_HTML_Helper {
|
||||
$this->_groupKey = $key;
|
||||
if ($checkLastModified) {
|
||||
if (! $this->groupsConfigFile) {
|
||||
$this->groupsConfigFile = dirname(dirname(dirname(dirname(__FILE__)))) . '/groupsConfig.php';
|
||||
$this->groupsConfigFile = dirname(dirname(dirname(__DIR__))) . '/groupsConfig.php';
|
||||
}
|
||||
if (is_file($this->groupsConfigFile)) {
|
||||
$gc = (require $this->groupsConfigFile);
|
@@ -68,7 +68,7 @@ class Minify_JS_ClosureCompiler {
|
||||
/**
|
||||
* @var callable Function to minify JS if service fails. Default is JSMin
|
||||
*/
|
||||
protected $fallbackMinifier = array('JSMin', 'minify');
|
||||
protected $fallbackMinifier = array('JSMin\\JSMin', 'minify');
|
||||
|
||||
/**
|
||||
* Minify JavaScript code via HTTP request to a Closure Compiler API
|
@@ -13,7 +13,7 @@
|
||||
class Minify_Loader {
|
||||
public function loadClass($class)
|
||||
{
|
||||
$file = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
|
||||
$file = dirname(__DIR__) . DIRECTORY_SEPARATOR;
|
||||
$file .= strtr($class, "\\_", DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . '.php';
|
||||
if (is_readable($file)) {
|
||||
require $file;
|
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
die('Must be rewritten for new API');
|
||||
|
||||
require __DIR__ . '/../../bootstrap.php';
|
||||
|
||||
$cli = new MrClay\Cli;
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
die('Must be rewritten for new API');
|
||||
|
||||
require __DIR__ . '/../../bootstrap.php';
|
||||
|
||||
$cli = new MrClay\Cli;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
// using same lib path and cache path specified in /min/config.php
|
||||
|
||||
require dirname(__FILE__) . '/../min/config.php';
|
||||
require __DIR__ . '/../config.php';
|
||||
|
||||
$minifyCachePath = isset($min_cachePath)
|
||||
? $min_cachePath
|
||||
|
@@ -31,7 +31,7 @@ if (isset($_POST['method']) && $_POST['method'] === 'Minify and serve') {
|
||||
$sourceSpec['content'] = $textIn;
|
||||
$sourceSpec['id'] = 'foo';
|
||||
if (isset($_POST['minJs'])) {
|
||||
$sourceSpec['minifyOptions']['jsMinifier'] = array('JSMin', 'minify');
|
||||
$sourceSpec['minifyOptions']['jsMinifier'] = array('JSMin\\JSMin', 'minify');
|
||||
}
|
||||
if (isset($_POST['minCss'])) {
|
||||
$sourceSpec['minifyOptions']['cssMinifier'] = array('Minify_CSS', 'minify');
|
||||
@@ -50,7 +50,7 @@ if (isset($_POST['method']) && $_POST['method'] === 'Minify and serve') {
|
||||
}
|
||||
|
||||
$tpl = array();
|
||||
$tpl['classes'] = array('Minify_HTML', 'JSMin', 'Minify_CSS', 'Minify_CSSmin', 'JSMinPlus');
|
||||
$tpl['classes'] = array('Minify_HTML', 'JSMin\\JSMin', 'Minify_CSS', 'Minify_CSSmin', 'JSMinPlus');
|
||||
|
||||
if (isset($_POST['method']) && in_array($_POST['method'], $tpl['classes'])) {
|
||||
|
||||
@@ -58,7 +58,7 @@ if (isset($_POST['method']) && in_array($_POST['method'], $tpl['classes'])) {
|
||||
if ($_POST['method'] === 'Minify_HTML') {
|
||||
$args[] = array(
|
||||
'cssMinifier' => array('Minify_CSS', 'minify')
|
||||
,'jsMinifier' => array('JSMin', 'minify')
|
||||
,'jsMinifier' => array('JSMin\\JSMin', 'minify')
|
||||
);
|
||||
}
|
||||
$func = array($_POST['method'], 'minify');
|
||||
|
@@ -96,7 +96,7 @@ if (isset($_POST['url'])) {
|
||||
|
||||
if ($type['minify'] === 'text/html') {
|
||||
if (isset($_POST['minJs'])) {
|
||||
$sourceSpec['minifyOptions']['jsMinifier'] = array('JSMin', 'minify');
|
||||
$sourceSpec['minifyOptions']['jsMinifier'] = array('JSMin\\JSMin', 'minify');
|
||||
}
|
||||
if (isset($_POST['minCss'])) {
|
||||
$sourceSpec['minifyOptions']['cssMinifier'] = array('Minify_CSS', 'minify');
|
||||
|
@@ -26,7 +26,7 @@ if (! empty($_POST)) {
|
||||
}
|
||||
}
|
||||
|
||||
$defaultCurrentDir = dirname(__FILE__);
|
||||
$defaultCurrentDir = __DIR__;
|
||||
$defaultDocRoot = realpath($_SERVER['DOCUMENT_ROOT']);
|
||||
$defaultSymLink = '//symlinkPath';
|
||||
$defaultSymTarget = ($defaultCurrentDir[0] === '/') ? '/tmp' : 'C:\\WINDOWS\\Temp';
|
||||
|
@@ -28,7 +28,7 @@ property is false, you echo the content.</p>
|
||||
|
||||
require '_include.php';
|
||||
|
||||
echo send_slowly(get_content(array(
|
||||
send_slowly(get_content(array(
|
||||
'title' => $title
|
||||
,'explain' => $explain
|
||||
)));
|
||||
|
@@ -33,7 +33,7 @@ p span {padding:0 .5em;}
|
||||
ob_end_clean();
|
||||
|
||||
} elseif ($_GET['test'] == '1') {
|
||||
$content = file_get_contents(dirname(__FILE__) . '/green.png');
|
||||
$content = file_get_contents(__DIR__ . '/green.png');
|
||||
$type = 'image/png';
|
||||
|
||||
} elseif ($_GET['test'] == '2') {
|
||||
|
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
// comment this out to run tests
|
||||
die('This script is disabled.');
|
||||
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
require __DIR__ . '/../min/config.php';
|
||||
require __DIR__ . '/../config.php';
|
||||
|
||||
// set cache path and doc root if configured
|
||||
$minifyCachePath = isset($min_cachePath)
|
||||
@@ -23,7 +25,7 @@ ini_set('display_errors', 1);
|
||||
|
||||
header('Content-Type: text/plain;charset=utf-8');
|
||||
|
||||
$thisDir = dirname(__FILE__);
|
||||
$thisDir = __DIR__;
|
||||
|
||||
/**
|
||||
* pTest - PHP Unit Tester
|
||||
|
3
min_unit_tests/_test_files/js/regexes.min.js
vendored
3
min_unit_tests/_test_files/js/regexes.min.js
vendored
@@ -1,3 +1,2 @@
|
||||
function testIssue74(){return/'/;}
|
||||
!function(s){return /^[£$€?.]/.test(s);}();typeof
|
||||
/ ' /;x=/ [/] /;1/foo;(2)/foo;function(){return/foo/};function(){return typeof/foo/};
|
||||
!function(s){return/^[£$€?.]/.test(s);}();typeof/ ' /;x=/ [/] /;1/foo;(2)/foo;function(){return/foo/};function(){return typeof/foo/};
|
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
require_once '_inc.php';
|
||||
|
||||
use JSMin\JSMin;
|
||||
|
||||
function test_JSMin()
|
||||
{
|
||||
global $thisDir;
|
||||
@@ -59,34 +61,34 @@ function test_JSMin()
|
||||
|
||||
test_JSMin_exception('"Hello'
|
||||
,'Unterminated String'
|
||||
,'JSMin_UnterminatedStringException'
|
||||
,'JSMin\UnterminatedStringException'
|
||||
,"JSMin: Unterminated String at byte 5: \"Hello");
|
||||
|
||||
test_JSMin_exception("return /regexp\n}"
|
||||
,'Unterminated RegExp'
|
||||
,'JSMin_UnterminatedRegExpException'
|
||||
,'JSMin\UnterminatedRegExpException'
|
||||
,"JSMin: Unterminated RegExp at byte 14: /regexp\n");
|
||||
test_JSMin_exception("return/regexp\n}"
|
||||
,'Unterminated RegExp'
|
||||
,'JSMin_UnterminatedRegExpException'
|
||||
,'JSMin\UnterminatedRegExpException'
|
||||
,"JSMin: Unterminated RegExp at byte 13: /regexp\n");
|
||||
test_JSMin_exception(";return/regexp\n}"
|
||||
,'Unterminated RegExp'
|
||||
,'JSMin_UnterminatedRegExpException'
|
||||
,'JSMin\UnterminatedRegExpException'
|
||||
,"JSMin: Unterminated RegExp at byte 14: /regexp\n");
|
||||
test_JSMin_exception(";return /regexp\n}"
|
||||
,'Unterminated RegExp'
|
||||
,'JSMin_UnterminatedRegExpException'
|
||||
,'JSMin\UnterminatedRegExpException'
|
||||
,"JSMin: Unterminated RegExp at byte 15: /regexp\n");
|
||||
|
||||
test_JSMin_exception("typeof/regexp\n}"
|
||||
,'Unterminated RegExp'
|
||||
,'JSMin_UnterminatedRegExpException'
|
||||
,'JSMin\UnterminatedRegExpException'
|
||||
,"JSMin: Unterminated RegExp at byte 13: /regexp\n");
|
||||
|
||||
test_JSMin_exception("/* Comment "
|
||||
,'Unterminated Comment'
|
||||
,'JSMin_UnterminatedCommentException'
|
||||
,'JSMin\UnterminatedCommentException'
|
||||
,"JSMin: Unterminated comment at byte 11: /* Comment ");
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,7 @@ function test_Minify()
|
||||
{
|
||||
global $thisDir;
|
||||
|
||||
$minifyTestPath = dirname(__FILE__) . '/_test_files/minify';
|
||||
$minifyTestPath = __DIR__ . '/_test_files/minify';
|
||||
$thisFileActive = (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME']));
|
||||
$tomorrow = $_SERVER['REQUEST_TIME'] + 86400;
|
||||
$lastModified = $_SERVER['REQUEST_TIME'] - 86400;
|
||||
@@ -19,6 +19,20 @@ function test_Minify()
|
||||
$_SERVER['HTTP_IF_NONE_MATCH'] = "\"{$lastModified}pub\"";
|
||||
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s \G\M\T', $lastModified);
|
||||
|
||||
$minify = new Minify(new Minify_Cache_Null());
|
||||
$env = new Minify_Env(array(
|
||||
'server' => $_SERVER,
|
||||
));
|
||||
$sourceFactory = new Minify_Source_Factory($env, array(), new Minify_Cache_Null());
|
||||
$controller = new Minify_Controller_Files($env, $sourceFactory);
|
||||
|
||||
$output = $minify->serve($controller, array(
|
||||
'files' => $thisDir . '/_test_files/css/styles.css' // controller casts to array
|
||||
,'quiet' => true
|
||||
,'lastModifiedTime' => $lastModified
|
||||
,'encodeOutput' => false
|
||||
));
|
||||
|
||||
$expected = array (
|
||||
'success' => true
|
||||
,'statusCode' => 304
|
||||
@@ -32,12 +46,7 @@ function test_Minify()
|
||||
'_responseCode' => 'HTTP/1.0 304 Not Modified',
|
||||
)
|
||||
);
|
||||
$output = Minify::serve('Files', array(
|
||||
'files' => $thisDir . '/_test_files/css/styles.css' // controller casts to array
|
||||
,'quiet' => true
|
||||
,'lastModifiedTime' => $lastModified
|
||||
,'encodeOutput' => false
|
||||
));
|
||||
|
||||
$passed = assertTrue($expected === $output, 'Minify : 304 response');
|
||||
if ($thisFileActive) {
|
||||
echo "\nOutput: " .var_export($output, 1). "\n\n";
|
||||
@@ -48,8 +57,7 @@ function test_Minify()
|
||||
|
||||
assertTrue(
|
||||
! class_exists('Minify_CSS', false)
|
||||
&& ! class_exists('Minify_Cache_File', false)
|
||||
,'Minify : cache, and minifier classes aren\'t loaded for 304s'
|
||||
,'Minify : minifier classes aren\'t loaded for 304s'
|
||||
);
|
||||
|
||||
// Test JS and Expires
|
||||
@@ -74,9 +82,16 @@ function test_Minify()
|
||||
'Content-Type' => 'application/x-javascript; charset=utf-8',
|
||||
)
|
||||
);
|
||||
|
||||
unset($_SERVER['HTTP_IF_NONE_MATCH']);
|
||||
unset($_SERVER['HTTP_IF_MODIFIED_SINCE']);
|
||||
$output = Minify::serve('Files', array(
|
||||
|
||||
$env = new Minify_Env(array(
|
||||
'server' => $_SERVER,
|
||||
));
|
||||
$sourceFactory = new Minify_Source_Factory($env, array(), new Minify_Cache_Null());
|
||||
$controller = new Minify_Controller_Files($env, $sourceFactory);
|
||||
$output = $minify->serve($controller, array(
|
||||
'files' => array(
|
||||
$minifyTestPath . '/email.js'
|
||||
,$minifyTestPath . '/QueryString.js'
|
||||
@@ -95,10 +110,8 @@ function test_Minify()
|
||||
}
|
||||
|
||||
// test for Issue 73
|
||||
Minify::setCache(null);
|
||||
|
||||
$expected = ";function h(){}";
|
||||
$output = Minify::serve('Files', array(
|
||||
$output = $minify->serve($controller, array(
|
||||
'files' => array(
|
||||
$minifyTestPath . '/issue73_1.js'
|
||||
,$minifyTestPath . '/issue73_2.js'
|
||||
@@ -118,7 +131,7 @@ function test_Minify()
|
||||
|
||||
// test for Issue 89
|
||||
$expected = file_get_contents($minifyTestPath . '/issue89_out.min.css');
|
||||
$output = Minify::serve('Files', array(
|
||||
$output = $minify->serve($controller, array(
|
||||
'files' => array(
|
||||
$minifyTestPath . '/issue89_1.css'
|
||||
,$minifyTestPath . '/issue89_2.css'
|
||||
@@ -136,7 +149,7 @@ function test_Minify()
|
||||
}
|
||||
}
|
||||
|
||||
$output = Minify::serve('Files', array(
|
||||
$output = $minify->serve($controller, array(
|
||||
'files' => array(
|
||||
$minifyTestPath . '/issue89_1.css'
|
||||
,$minifyTestPath . '/issue89_2.css'
|
||||
@@ -145,7 +158,10 @@ function test_Minify()
|
||||
,'encodeOutput' => false
|
||||
));
|
||||
$output = $output['content'];
|
||||
$passed = assertTrue(0 === strpos($output, Minify::$importWarning), 'Minify : Issue 89 : detect invalid imports');
|
||||
|
||||
$defaultOptions = $minify->getDefaultOptions();
|
||||
|
||||
$passed = assertTrue(0 === strpos($output, $defaultOptions['importWarning']), 'Minify : Issue 89 : detect invalid imports');
|
||||
if ($thisFileActive) {
|
||||
if (! $passed) {
|
||||
echo "\n---Output : " .var_export($output, 1). "\n";
|
||||
@@ -153,7 +169,7 @@ function test_Minify()
|
||||
}
|
||||
}
|
||||
|
||||
$output = Minify::serve('Files', array(
|
||||
$output = $minify->serve($controller, array(
|
||||
'files' => array(
|
||||
$minifyTestPath . '/issue89_1.css'
|
||||
)
|
||||
@@ -161,7 +177,7 @@ function test_Minify()
|
||||
,'encodeOutput' => false
|
||||
));
|
||||
$output = $output['content'];
|
||||
$passed = assertTrue(false === strpos($output, Minify::$importWarning), 'Minify : Issue 89 : don\'t warn about valid imports');
|
||||
$passed = assertTrue(false === strpos($output, $defaultOptions['importWarning']), 'Minify : Issue 89 : don\'t warn about valid imports');
|
||||
if ($thisFileActive) {
|
||||
if (! $passed) {
|
||||
echo "\n---Output : " .var_export($output, 1). "\n";
|
||||
@@ -171,8 +187,8 @@ function test_Minify()
|
||||
|
||||
// Test Issue 132
|
||||
if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
|
||||
$output = Minify::serve('Files', array(
|
||||
'files' => array(dirname(__FILE__) . '/_test_files/js/issue132.js')
|
||||
$output = $minify->serve($controller, array(
|
||||
'files' => array(__DIR__ . '/_test_files/js/issue132.js')
|
||||
,'quiet' => true
|
||||
,'encodeOutput' => false
|
||||
));
|
||||
@@ -199,7 +215,14 @@ function test_Minify()
|
||||
'Content-Type' => 'text/css; charset=utf-8',
|
||||
)
|
||||
);
|
||||
$output = Minify::serve('Files', array(
|
||||
|
||||
$env = new Minify_Env(array(
|
||||
'server' => $_SERVER,
|
||||
));
|
||||
$sourceFactory = new Minify_Source_Factory($env, array(), new Minify_Cache_Null());
|
||||
$controller = new Minify_Controller_Files($env, $sourceFactory);
|
||||
|
||||
$output = $minify->serve($controller, array(
|
||||
'files' => array(
|
||||
$thisDir . '/_test_files/css/styles.css'
|
||||
,$thisDir . '/_test_files/css/comments.css'
|
||||
|
@@ -5,7 +5,7 @@ function test_CSS()
|
||||
{
|
||||
global $thisDir;
|
||||
|
||||
$cssPath = dirname(__FILE__) . '/_test_files/css';
|
||||
$cssPath = __DIR__ . '/_test_files/css';
|
||||
|
||||
// build test file list
|
||||
$d = dir($cssPath);
|
||||
|
@@ -11,7 +11,7 @@ function test_HTML()
|
||||
$time = microtime(true);
|
||||
$minOutput = Minify_HTML::minify($src, array(
|
||||
'cssMinifier' => array('Minify_CSS', 'minify')
|
||||
,'jsMinifier' => array('JSMin', 'minify')
|
||||
,'jsMinifier' => array('JSMin\\JSMin', 'minify')
|
||||
));
|
||||
$time = microtime(true) - $time;
|
||||
|
||||
@@ -34,7 +34,7 @@ function test_HTML()
|
||||
$time = microtime(true);
|
||||
$minOutput = Minify_HTML::minify($src, array(
|
||||
'cssMinifier' => array('Minify_CSS', 'minify')
|
||||
,'jsMinifier' => array('JSMin', 'minify')
|
||||
,'jsMinifier' => array('JSMin\\JSMin', 'minify')
|
||||
));
|
||||
$time = microtime(true) - $time;
|
||||
|
||||
|
@@ -35,7 +35,7 @@ function test_Minify_HTML_Helper()
|
||||
));
|
||||
$passed = assertTrue($actual === $expected, 'Minify_HTML_Helper : existing group');
|
||||
|
||||
$utilsFile = dirname(dirname(__FILE__)) . '/min/utils.php';
|
||||
$utilsFile = dirname(__DIR__) . '/min/utils.php';
|
||||
if (is_file($utilsFile)) {
|
||||
require_once $utilsFile;
|
||||
|
||||
|
@@ -8,9 +8,12 @@ function test_Lines()
|
||||
|
||||
$exp = file_get_contents("{$thisDir}/_test_files/minify/lines_output.js");
|
||||
|
||||
Minify::setCache(null); // no cache
|
||||
$env = new Minify_Env();
|
||||
$sourceFactory = new Minify_Source_Factory($env, array(), new Minify_Cache_Null());
|
||||
$controller = new Minify_Controller_Files($env, $sourceFactory);
|
||||
$minify = new Minify(new Minify_Cache_Null());
|
||||
|
||||
$ret = Minify::serve('Files', array(
|
||||
$ret = $minify->serve($controller, array(
|
||||
'debug' => true
|
||||
,'quiet' => true
|
||||
,'encodeOutput' => false
|
||||
|
@@ -4,13 +4,13 @@
|
||||
*
|
||||
* @warning These functions execute min/groupsConfig.php, sometimes multiple times.
|
||||
* You must make sure that functions are not redefined, and if your use custom sources,
|
||||
* you must require_once dirname(__FILE__) . '/lib/Minify/Source.php' so that
|
||||
* you must require_once __DIR__ . '/lib/Minify/Source.php' so that
|
||||
* class is available.
|
||||
*
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
require __DIR__ . '/../bootstrap.php';
|
||||
require __DIR__ . '/bootstrap.php';
|
||||
|
||||
/*
|
||||
* Get an HTML-escaped Minify URI for a group or set of files. By default, URIs
|
||||
@@ -56,7 +56,7 @@ function Minify_mtime($keysAndFiles, $groupsConfigFile = null)
|
||||
{
|
||||
$gc = null;
|
||||
if (! $groupsConfigFile) {
|
||||
$groupsConfigFile = dirname(__FILE__) . '/groupsConfig.php';
|
||||
$groupsConfigFile = __DIR__ . '/groupsConfig.php';
|
||||
}
|
||||
$sources = array();
|
||||
foreach ($keysAndFiles as $keyOrFile) {
|
Reference in New Issue
Block a user