mirror of
https://github.com/mrclay/minify.git
synced 2025-09-06 12:10:45 +02:00
Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
e1c8b925be | ||
|
9eb43c9f9f | ||
|
5597771d6e | ||
|
2d5ca3614e | ||
|
1a8cdbb6c7 | ||
|
c222c65211 | ||
|
60f49fa1e3 | ||
|
230770a277 | ||
|
14b1d60448 | ||
|
43fb768c13 | ||
|
6166d3b785 | ||
|
e84d55d4d6 | ||
|
45463786f8 | ||
|
00e5e20abe | ||
|
9e182a6255 | ||
|
bc1ffdc5fc | ||
|
aa3721156e | ||
|
3047f5c48f | ||
|
104ccd2bfe |
54
.github/workflows/php.yml
vendored
Normal file
54
.github/workflows/php.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
name: PHP Composer
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "master" ]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
php-versions:
|
||||||
|
["8.1", "8.2", "8.3", "8.4"]
|
||||||
|
|
||||||
|
name: PHP ${{ matrix.php-versions }} Test on ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
coverage: none
|
||||||
|
tools: composer, wp-cli, phpunit-polyfills:1.0
|
||||||
|
env:
|
||||||
|
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Validate composer.json and composer.lock
|
||||||
|
run: composer validate --strict
|
||||||
|
|
||||||
|
- name: Cache Composer packages
|
||||||
|
id: composer-cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: vendor
|
||||||
|
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-php-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --prefer-dist --no-progress
|
||||||
|
|
||||||
|
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
|
||||||
|
# Docs: https://getcomposer.org/doc/articles/scripts.md
|
||||||
|
|
||||||
|
- name: Run test suite
|
||||||
|
run: composer run-script test
|
4
.semver
4
.semver
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
:major: 3
|
:major: 4
|
||||||
:minor: 0
|
:minor: 0
|
||||||
:patch: 11
|
:patch: 1
|
||||||
:special: ''
|
:special: ''
|
||||||
:metadata: ''
|
:metadata: ''
|
||||||
|
55
.travis.yml
55
.travis.yml
@@ -1,55 +0,0 @@
|
|||||||
language: php
|
|
||||||
sudo: false
|
|
||||||
dist: trusty
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
fast_finish: true
|
|
||||||
allow_failures:
|
|
||||||
- php: "nightly"
|
|
||||||
- name: "Php CS Fixer"
|
|
||||||
include:
|
|
||||||
- php: "5.3"
|
|
||||||
dist: precise
|
|
||||||
- php: "5.4"
|
|
||||||
- php: "5.5"
|
|
||||||
- php: "5.6"
|
|
||||||
- php: "7.0"
|
|
||||||
- php: "7.1"
|
|
||||||
- php: "7.2"
|
|
||||||
- php: "7.3"
|
|
||||||
- php: "7.4"
|
|
||||||
- php: "nightly"
|
|
||||||
- name: "Php CS Fixer"
|
|
||||||
php: "7.3"
|
|
||||||
env:
|
|
||||||
- PHP_CS_FIXER=1
|
|
||||||
|
|
||||||
env:
|
|
||||||
- CLOSURE_VERSION: 20161024
|
|
||||||
|
|
||||||
services:
|
|
||||||
- memcached
|
|
||||||
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- $HOME/.composer/cache
|
|
||||||
- vendor
|
|
||||||
|
|
||||||
install:
|
|
||||||
- composer update --no-interaction --prefer-source
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- tests/dl-closure.sh
|
|
||||||
|
|
||||||
script:
|
|
||||||
- PATH=vendor/bin:$PATH
|
|
||||||
- composer validate
|
|
||||||
- |
|
|
||||||
if [ "$PHP_CS_FIXER" ]; then
|
|
||||||
composer config --unset platform.php
|
|
||||||
composer require --dev friendsofphp/php-cs-fixer:2.16
|
|
||||||
php-cs-fixer fix --verbose --diff --dry-run --ansi
|
|
||||||
fi
|
|
||||||
- vendor/bin/phpunit --verbose
|
|
||||||
|
|
||||||
# vim:ts=2:sw=2:et
|
|
21
CHANGELOG.md
21
CHANGELOG.md
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
## [4.0.1] - 2025-02-03
|
||||||
|
|
||||||
|
- Recommend against use, [#711]
|
||||||
|
- Fix htmlspecialchars incompatibility with php 8.1, [#693]
|
||||||
|
- Support PHP 8.4, [#714]
|
||||||
|
|
||||||
|
[4.0.1]: https://github.com/mrclay/minify/compare/4.0.0...4.0.1
|
||||||
|
[#711]: https://github.com/mrclay/minify/pull/711
|
||||||
|
[#693]: https://github.com/mrclay/minify/issues/693
|
||||||
|
[#714]: https://github.com/mrclay/minify/pull/714
|
||||||
|
|
||||||
|
## [4.0.0] - 2024-01-04
|
||||||
|
|
||||||
|
- Support PHP 8.1+
|
||||||
|
- Update PHPUnit to 8.x
|
||||||
|
- Replace `leafo/scssphp` with `scssphp/scssphp`
|
||||||
|
|
||||||
|
[4.0.0]: https://github.com/mrclay/minify/compare/3.0.14...4.0.0
|
||||||
|
|
||||||
## [3.0.14] - 2023-05-05
|
## [3.0.14] - 2023-05-05
|
||||||
|
|
||||||
- Support monolog v3, [#705]
|
- Support monolog v3, [#705]
|
||||||
|
@@ -1,4 +1,10 @@
|
|||||||
# Welcome to Minify!
|
## Minify is no longer regularly maintained
|
||||||
|
|
||||||
|
The original authors no longer recommend using Minify, especially previous versions, which were not designed to handle modern JS and CSS syntax. Instead, use an up-to-date performance measurement tool like [Lighthouse](https://developer.chrome.com/docs/lighthouse/overview) and follow its recommendations.
|
||||||
|
|
||||||
|
In 2010, Minify offered a fine improvement for some websites, but browsers and HTTP servers are now much better, and Minify may offer only a marginal performance benefit in narrow cases. Also both JS and CSS now change rapidly, and new syntaxes are likely to lead to broken code being served through Minify.
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
Minify is an HTTP server for JS and CSS assets. It compresses and combines files
|
Minify is an HTTP server for JS and CSS assets. It compresses and combines files
|
||||||
and serves it with appropriate headers, allowing conditional GET or long-Expires.
|
and serves it with appropriate headers, allowing conditional GET or long-Expires.
|
||||||
|
@@ -17,32 +17,36 @@
|
|||||||
"wiki": "https://github.com/mrclay/minify/blob/master/docs"
|
"wiki": "https://github.com/mrclay/minify/blob/master/docs"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"classmap": ["lib/"]
|
"classmap": [
|
||||||
|
"lib/"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {"Minify\\Test\\": "tests/"}
|
"psr-4": {
|
||||||
|
"Minify\\Test\\": "tests/"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": "5.3.29"
|
"php": "8.1.0"
|
||||||
},
|
},
|
||||||
"sort-packages": true
|
"sort-packages": true
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^5.3.0 || ^7.0 || ^8.0",
|
"php": "^8.1",
|
||||||
"ext-pcre": "*",
|
"ext-pcre": "*",
|
||||||
"intervention/httpauth": "^2.0|^3.0",
|
"intervention/httpauth": "^2.0|^3.0",
|
||||||
"marcusschwarz/lesserphp": "^0.5.5",
|
"marcusschwarz/lesserphp": "^0.5.5",
|
||||||
"monolog/monolog": "~1.1|~2.0|~3.0",
|
"monolog/monolog": "~1.1|~2.0|~3.0",
|
||||||
"mrclay/jsmin-php": "~2",
|
"mrclay/jsmin-php": "~2",
|
||||||
"mrclay/props-dic": "^2.2|^3.0",
|
"mrclay/props-dic": "^4",
|
||||||
"tubalmartin/cssmin": "~4"
|
"tubalmartin/cssmin": "~4"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"firephp/firephp-core": "~0.4.0",
|
"firephp/firephp-core": "~0.4.0",
|
||||||
"leafo/scssphp": "^0.3 || ^0.6 || ^0.7",
|
|
||||||
"meenie/javascript-packer": "~1.1",
|
"meenie/javascript-packer": "~1.1",
|
||||||
"phpunit/phpunit": "^4.8.36",
|
"phpunit/phpunit": "^8",
|
||||||
|
"scssphp/scssphp": "^1.12",
|
||||||
"tedivm/jshrink": "~1.1.0"
|
"tedivm/jshrink": "~1.1.0"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
|
8
docker-compose.yml
Normal file
8
docker-compose.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
version: "3.7"
|
||||||
|
services:
|
||||||
|
apache:
|
||||||
|
image: php:8.3-apache
|
||||||
|
ports:
|
||||||
|
- 8080:80
|
||||||
|
volumes:
|
||||||
|
- .:/var/www/html/min
|
@@ -85,7 +85,7 @@ class Minify
|
|||||||
* @param Minify_CacheInterface $cache
|
* @param Minify_CacheInterface $cache
|
||||||
* @param LoggerInterface $logger
|
* @param LoggerInterface $logger
|
||||||
*/
|
*/
|
||||||
public function __construct(Minify_CacheInterface $cache, LoggerInterface $logger = null)
|
public function __construct(Minify_CacheInterface $cache, ?LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
@@ -471,7 +471,7 @@ class Minify
|
|||||||
*/
|
*/
|
||||||
public function errorExit($header, $url = '', $msgHtml = '')
|
public function errorExit($header, $url = '', $msgHtml = '')
|
||||||
{
|
{
|
||||||
$url = htmlspecialchars($url, ENT_QUOTES);
|
$url = htmlspecialchars($url);
|
||||||
list(, $h1) = explode(' ', $header, 2);
|
list(, $h1) = explode(' ', $header, 2);
|
||||||
$h1 = htmlspecialchars($h1);
|
$h1 = htmlspecialchars($h1);
|
||||||
// FastCGI environments require 3rd arg to header() to be set
|
// FastCGI environments require 3rd arg to header() to be set
|
||||||
|
@@ -232,7 +232,7 @@ class App extends Container
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check for URI versioning
|
// 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;
|
$ret['maxAge'] = 31536000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ class Minify_Cache_File implements Minify_CacheInterface
|
|||||||
* @param bool $fileLocking
|
* @param bool $fileLocking
|
||||||
* @param LoggerInterface $logger
|
* @param LoggerInterface $logger
|
||||||
*/
|
*/
|
||||||
public function __construct($path = '', $fileLocking = false, LoggerInterface $logger = null)
|
public function __construct($path = '', $fileLocking = false, ?LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
if (! $path) {
|
if (! $path) {
|
||||||
$path = sys_get_temp_dir();
|
$path = sys_get_temp_dir();
|
||||||
|
@@ -188,7 +188,7 @@ class Minify_ClosureCompiler
|
|||||||
*/
|
*/
|
||||||
protected function checkTempdir($tempDir)
|
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.');
|
throw new Minify_ClosureCompiler_Exception('$tempDir(' . $tempDir . ') is not a valid direcotry.');
|
||||||
}
|
}
|
||||||
if (!is_writable($tempDir)) {
|
if (!is_writable($tempDir)) {
|
||||||
|
@@ -38,7 +38,7 @@ abstract class Minify_Controller_Base implements Minify_ControllerInterface
|
|||||||
* @param Minify_Source_Factory $sourceFactory
|
* @param Minify_Source_Factory $sourceFactory
|
||||||
* @param LoggerInterface $logger
|
* @param LoggerInterface $logger
|
||||||
*/
|
*/
|
||||||
public function __construct(Minify_Env $env, Minify_Source_Factory $sourceFactory, LoggerInterface $logger = null)
|
public function __construct(Minify_Env $env, Minify_Source_Factory $sourceFactory, ?LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
$this->env = $env;
|
$this->env = $env;
|
||||||
$this->sourceFactory = $sourceFactory;
|
$this->sourceFactory = $sourceFactory;
|
||||||
|
@@ -52,7 +52,7 @@ class Minify_HTML_Helper
|
|||||||
}
|
}
|
||||||
$uri = $h->getRawUri($opts['farExpires'], $opts['debug']);
|
$uri = $h->getRawUri($opts['farExpires'], $opts['debug']);
|
||||||
|
|
||||||
return htmlspecialchars($uri, ENT_QUOTES, $opts['charset']);
|
return htmlspecialchars($uri, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, $opts['charset']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -163,7 +163,7 @@ class Minify_HTML_Helper
|
|||||||
* @return \Minify\App
|
* @return \Minify\App
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public static function app(\Minify\App $app = null)
|
public static function app(?\Minify\App $app = null)
|
||||||
{
|
{
|
||||||
static $cached;
|
static $cached;
|
||||||
if ($app) {
|
if ($app) {
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
use Leafo\ScssPhp\Compiler;
|
use ScssPhp\ScssPhp\Compiler;
|
||||||
use Leafo\ScssPhp\Server;
|
use ScssPhp\ScssPhp\Version;
|
||||||
use Leafo\ScssPhp\Version;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for using SCSS files
|
* Class for using SCSS files
|
||||||
@@ -152,12 +151,12 @@ class Minify_ScssCssSource extends Minify_Source
|
|||||||
// and will treat the @import line as css import
|
// and will treat the @import line as css import
|
||||||
$scss->setImportPaths(dirname($filename));
|
$scss->setImportPaths(dirname($filename));
|
||||||
|
|
||||||
$css = $scss->compile(file_get_contents($filename), $filename);
|
$css = $scss->compileString(file_get_contents($filename), $filename)->getCss();
|
||||||
$elapsed = round((microtime(true) - $start), 4);
|
$elapsed = round((microtime(true) - $start), 4);
|
||||||
|
|
||||||
$v = Version::VERSION;
|
$v = Version::VERSION;
|
||||||
$ts = date('r', $start);
|
$ts = date('r', (int) $start);
|
||||||
$css = "/* compiled by scssphp $v on $ts (${elapsed}s) */\n\n" . $css;
|
$css = "/* compiled by scssphp $v on $ts ({$elapsed}s) */\n\n" . $css;
|
||||||
|
|
||||||
$imports = $scss->getParsedFiles();
|
$imports = $scss->getParsedFiles();
|
||||||
|
|
||||||
|
@@ -44,7 +44,7 @@ class Minify_Source_Factory
|
|||||||
* @param Minify_CacheInterface $cache Optional cache for handling .less files.
|
* @param Minify_CacheInterface $cache Optional cache for handling .less files.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function __construct(Minify_Env $env, array $options = array(), Minify_CacheInterface $cache = null)
|
public function __construct(Minify_Env $env, array $options = array(), ?Minify_CacheInterface $cache = null)
|
||||||
{
|
{
|
||||||
$this->env = $env;
|
$this->env = $env;
|
||||||
$this->options = array_merge(array(
|
$this->options = array_merge(array(
|
||||||
|
@@ -108,7 +108,7 @@ class Cli
|
|||||||
* @return Arg
|
* @return Arg
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function addArgument($letter, $required, Arg $arg = null)
|
public function addArgument($letter, $required, ?Arg $arg = null)
|
||||||
{
|
{
|
||||||
if (! preg_match('/^[a-zA-Z]$/', $letter)) {
|
if (! preg_match('/^[a-zA-Z]$/', $letter)) {
|
||||||
throw new InvalidArgumentException('$letter must be in [a-zA-Z]');
|
throw new InvalidArgumentException('$letter must be in [a-zA-Z]');
|
||||||
|
@@ -113,10 +113,12 @@ class HTTPEncoderTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($encodingTests as $test) {
|
foreach ($encodingTests as $test) {
|
||||||
$e = new HTTP_Encoder(array(
|
$e = new HTTP_Encoder(
|
||||||
|
array(
|
||||||
'content' => $variedContent,
|
'content' => $variedContent,
|
||||||
'method' => $test['method'],
|
'method' => $test['method'],
|
||||||
));
|
)
|
||||||
|
);
|
||||||
$e->encode(9);
|
$e->encode(9);
|
||||||
$ret = $this->countBytes($e->getContent());
|
$ret = $this->countBytes($e->getContent());
|
||||||
|
|
||||||
@@ -153,7 +155,7 @@ function _gzdecode($data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// http://www.php.net/manual/en/function.gzdecode.php#82930
|
// 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;
|
$mbIntEnc = null;
|
||||||
$hasMbOverload = (function_exists('mb_strlen')
|
$hasMbOverload = (function_exists('mb_strlen')
|
||||||
|
@@ -6,7 +6,9 @@ use Minify_HTML_Helper;
|
|||||||
|
|
||||||
class LessSourceTest extends TestCase
|
class LessSourceTest extends TestCase
|
||||||
{
|
{
|
||||||
public function setUp()
|
public string $realDocRoot;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->realDocRoot = $_SERVER['DOCUMENT_ROOT'];
|
$this->realDocRoot = $_SERVER['DOCUMENT_ROOT'];
|
||||||
$_SERVER['DOCUMENT_ROOT'] = self::$document_root;
|
$_SERVER['DOCUMENT_ROOT'] = self::$document_root;
|
||||||
|
@@ -6,7 +6,7 @@ use Minify_CSS_UriRewriter;
|
|||||||
|
|
||||||
class MinifyCSSUriRewriterTest extends TestCase
|
class MinifyCSSUriRewriterTest extends TestCase
|
||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
Minify_CSS_UriRewriter::$debugText = '';
|
Minify_CSS_UriRewriter::$debugText = '';
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use Minify_Cache_APC;
|
|||||||
|
|
||||||
class MinifyCacheAPCTest extends TestCase
|
class MinifyCacheAPCTest extends TestCase
|
||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
if (!function_exists('apc_store')) {
|
if (!function_exists('apc_store')) {
|
||||||
$this->markTestSkipped("To test this component, install APC extension");
|
$this->markTestSkipped("To test this component, install APC extension");
|
||||||
|
@@ -6,8 +6,13 @@ use Minify_Cache_APCu;
|
|||||||
|
|
||||||
class MinifyCacheAPCuTest extends TestCase
|
class MinifyCacheAPCuTest extends TestCase
|
||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
|
if (getenv('GITHUB_ACTION')) {
|
||||||
|
$this->markTestSkipped("Skipping on CI");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!function_exists('apcu_store')) {
|
if (!function_exists('apcu_store')) {
|
||||||
$this->markTestSkipped("To test this component, install APCu extension");
|
$this->markTestSkipped("To test this component, install APCu extension");
|
||||||
}
|
}
|
||||||
|
@@ -10,8 +10,13 @@ class MinifyCacheMemcacheTest extends TestCase
|
|||||||
/** @var Memcache */
|
/** @var Memcache */
|
||||||
private $mc;
|
private $mc;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
|
if (getenv('GITHUB_ACTION')) {
|
||||||
|
$this->markTestSkipped("Skipping on CI");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!function_exists('memcache_set')) {
|
if (!function_exists('memcache_set')) {
|
||||||
$this->markTestSkipped("To test this component, install memcache in PHP");
|
$this->markTestSkipped("To test this component, install memcache in PHP");
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ use Minify_Cache_WinCache;
|
|||||||
|
|
||||||
class MinifyCacheWinCacheTest extends TestCase
|
class MinifyCacheWinCacheTest extends TestCase
|
||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
if (!function_exists('wincache_ucache_info')) {
|
if (!function_exists('wincache_ucache_info')) {
|
||||||
$this->markTestSkipped("To test this component, install WinCache extension");
|
$this->markTestSkipped("To test this component, install WinCache extension");
|
||||||
|
@@ -6,7 +6,7 @@ use Minify_Cache_ZendPlatform;
|
|||||||
|
|
||||||
class MinifyCacheZendPlatformTest extends TestCase
|
class MinifyCacheZendPlatformTest extends TestCase
|
||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
if (!function_exists('output_cache_put')) {
|
if (!function_exists('output_cache_put')) {
|
||||||
// FIXME: be specific what to actually install
|
// FIXME: be specific what to actually install
|
||||||
|
@@ -7,7 +7,7 @@ use Minify_ClosureCompiler;
|
|||||||
|
|
||||||
class MinifyClosureCompilerTest extends TestCase
|
class MinifyClosureCompilerTest extends TestCase
|
||||||
{
|
{
|
||||||
public static function setupBeforeClass()
|
public static function setupBeforeClass(): void
|
||||||
{
|
{
|
||||||
parent::setupBeforeClass();
|
parent::setupBeforeClass();
|
||||||
Minify_ClosureCompiler::$isDebug = true;
|
Minify_ClosureCompiler::$isDebug = true;
|
||||||
|
@@ -9,14 +9,14 @@ class MinifyHTMLHelperTest extends TestCase
|
|||||||
{
|
{
|
||||||
private $realDocRoot;
|
private $realDocRoot;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->realDocRoot = $_SERVER['DOCUMENT_ROOT'];
|
$this->realDocRoot = $_SERVER['DOCUMENT_ROOT'];
|
||||||
$_SERVER['DOCUMENT_ROOT'] = self::$document_root;
|
$_SERVER['DOCUMENT_ROOT'] = self::$document_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this is probably not needed if backupGlobals is enabled?
|
// TODO: this is probably not needed if backupGlobals is enabled?
|
||||||
public function tearDown()
|
public function tearDown(): void
|
||||||
{
|
{
|
||||||
$_SERVER['DOCUMENT_ROOT'] = $this->realDocRoot;
|
$_SERVER['DOCUMENT_ROOT'] = $this->realDocRoot;
|
||||||
}
|
}
|
||||||
@@ -43,13 +43,16 @@ class MinifyHTMLHelperTest extends TestCase
|
|||||||
$this->assertEquals($expected, $actual, 'non-existent group & debug');
|
$this->assertEquals($expected, $actual, 'non-existent group & debug');
|
||||||
|
|
||||||
$expected = "/myApp/min/?g=css&{$maxTime}";
|
$expected = "/myApp/min/?g=css&{$maxTime}";
|
||||||
$actual = Minify_HTML_Helper::getUri('css', array(
|
$actual = Minify_HTML_Helper::getUri(
|
||||||
|
'css',
|
||||||
|
array(
|
||||||
'rewriteWorks' => false
|
'rewriteWorks' => false
|
||||||
,
|
,
|
||||||
'minAppUri' => '/myApp/min/'
|
'minAppUri' => '/myApp/min/'
|
||||||
,
|
,
|
||||||
'groupsConfigFile' => self::$test_files . '/htmlHelper_groupsConfig.php'
|
'groupsConfigFile' => self::$test_files . '/htmlHelper_groupsConfig.php'
|
||||||
));
|
)
|
||||||
|
);
|
||||||
$this->assertEquals($expected, $actual, 'existing group');
|
$this->assertEquals($expected, $actual, 'existing group');
|
||||||
|
|
||||||
|
|
||||||
@@ -58,25 +61,32 @@ class MinifyHTMLHelperTest extends TestCase
|
|||||||
require_once $utilsFile;
|
require_once $utilsFile;
|
||||||
|
|
||||||
$fiveSecondsAgo = $_SERVER['REQUEST_TIME'] - 5;
|
$fiveSecondsAgo = $_SERVER['REQUEST_TIME'] - 5;
|
||||||
$obj = new Minify_Source(array(
|
$obj = new Minify_Source(
|
||||||
|
array(
|
||||||
'id' => '1',
|
'id' => '1',
|
||||||
'content' => '1',
|
'content' => '1',
|
||||||
'lastModified' => $fiveSecondsAgo,
|
'lastModified' => $fiveSecondsAgo,
|
||||||
));
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$output = Minify_mtime(array($uri1, $uri2, $obj));
|
$output = Minify_mtime(array($uri1, $uri2, $obj));
|
||||||
$this->assertEquals($fiveSecondsAgo, $output, 'utils.php : Minify_mtime w/ files & obj');
|
$this->assertEquals($fiveSecondsAgo, $output, 'utils.php : Minify_mtime w/ files & obj');
|
||||||
|
|
||||||
$obj = new Minify_Source(array(
|
$obj = new Minify_Source(
|
||||||
|
array(
|
||||||
'id' => '2',
|
'id' => '2',
|
||||||
'content' => '2',
|
'content' => '2',
|
||||||
'lastModified' => strtotime('2000-01-01'),
|
'lastModified' => strtotime('2000-01-01'),
|
||||||
));
|
)
|
||||||
$output = Minify_mtime(array(
|
);
|
||||||
|
$output = Minify_mtime(
|
||||||
|
array(
|
||||||
$obj
|
$obj
|
||||||
,
|
,
|
||||||
'css'
|
'css'
|
||||||
), self::$test_files . '/htmlHelper_groupsConfig.php');
|
),
|
||||||
|
self::$test_files . '/htmlHelper_groupsConfig.php'
|
||||||
|
);
|
||||||
$this->assertEquals($maxTime, $output, 'utils.php : Minify_mtime w/ obj & group');
|
$this->assertEquals($maxTime, $output, 'utils.php : Minify_mtime w/ obj & group');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@ use Minify_NailgunClosureCompiler;
|
|||||||
|
|
||||||
class MinifyNailgunClosureCompilerTest extends TestCase
|
class MinifyNailgunClosureCompilerTest extends TestCase
|
||||||
{
|
{
|
||||||
public static function setupBeforeClass()
|
public static function setupBeforeClass(): void
|
||||||
{
|
{
|
||||||
parent::setupBeforeClass();
|
parent::setupBeforeClass();
|
||||||
Minify_ClosureCompiler::$isDebug = true;
|
Minify_ClosureCompiler::$isDebug = true;
|
||||||
|
@@ -7,7 +7,7 @@ use Minify_YUICompressor;
|
|||||||
|
|
||||||
class MinifyYuiCSSTest extends TestCase
|
class MinifyYuiCSSTest extends TestCase
|
||||||
{
|
{
|
||||||
public static function setupBeforeClass()
|
public static function setupBeforeClass(): void
|
||||||
{
|
{
|
||||||
parent::setupBeforeClass();
|
parent::setupBeforeClass();
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ class MinifyYuiCSSTest extends TestCase
|
|||||||
Minify_YUICompressor::$tempDir = sys_get_temp_dir();
|
Minify_YUICompressor::$tempDir = sys_get_temp_dir();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->assertHasJar();
|
$this->assertHasJar();
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,9 @@ use Minify_HTML_Helper;
|
|||||||
|
|
||||||
class ScssSourceTest extends TestCase
|
class ScssSourceTest extends TestCase
|
||||||
{
|
{
|
||||||
public function setUp()
|
public string $realDocRoot;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->realDocRoot = $_SERVER['DOCUMENT_ROOT'];
|
$this->realDocRoot = $_SERVER['DOCUMENT_ROOT'];
|
||||||
$_SERVER['DOCUMENT_ROOT'] = self::$document_root;
|
$_SERVER['DOCUMENT_ROOT'] = self::$document_root;
|
||||||
|
@@ -11,7 +11,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
|
|||||||
/** @var string */
|
/** @var string */
|
||||||
protected static $test_files;
|
protected static $test_files;
|
||||||
|
|
||||||
public static function setupBeforeClass()
|
public static function setupBeforeClass(): void
|
||||||
{
|
{
|
||||||
self::$document_root = __DIR__;
|
self::$document_root = __DIR__;
|
||||||
self::$test_files = __DIR__ . '/_test_files';
|
self::$test_files = __DIR__ . '/_test_files';
|
||||||
|
Reference in New Issue
Block a user