mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-21 16:01:53 +00:00
Run CSSTidy tests on CI (#338)
* Run CSSTidy tests on CI * update dirname * use compopser instead of git clone * use composer * use test-settings.sample.php * enable ext-intl * disable Net_IDNA2
This commit is contained in:
parent
f1d6da13bc
commit
25824056ee
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
@ -22,12 +22,15 @@ jobs:
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
tools: composer:v2
|
||||
ini-values: error_reporting=E_ALL
|
||||
extensions: iconv, bcmath, tidy, mbstring, intl
|
||||
|
||||
- name: Clone simpletest
|
||||
run: git clone --depth=50 https://github.com/ezyang/simpletest.git
|
||||
- name: Install dependencies
|
||||
run: composer install
|
||||
|
||||
- name: Configure simpletest
|
||||
run: cp test-settings.travis.php test-settings.php
|
||||
run: cp test-settings.sample.php test-settings.php
|
||||
|
||||
- name: Execute Unit tests
|
||||
run: php tests/index.php
|
||||
|
@ -15,6 +15,10 @@
|
||||
"require": {
|
||||
"php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"cerdic/css-tidy": "^1.7 || ^2.0",
|
||||
"simpletest/simpletest": "dev-master"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "HTMLPurifier": "library/" },
|
||||
"files": ["library/HTMLPurifier.composer.php"],
|
||||
@ -27,5 +31,14 @@
|
||||
"ext-iconv": "Converts text to and from non-UTF-8 encodings",
|
||||
"ext-bcmath": "Used for unit conversion and imagecrash protection",
|
||||
"ext-tidy": "Used for pretty-printing HTML"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/ezyang/simpletest.git"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
header('Content-type: text/html; charset=UTF-8');
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
if (!isset($_GET['standalone'])) {
|
||||
require_once '../library/HTMLPurifier.auto.php';
|
||||
} else {
|
||||
|
@ -3,23 +3,6 @@
|
||||
require_once 'common.php';
|
||||
require_once 'HTMLPurifier/Filter/ExtractStyleBlocks.php';
|
||||
|
||||
// need CSSTidy location
|
||||
$csstidy_location = false;
|
||||
if (file_exists('../conf/test-settings.php')) include '../conf/test-settings.php';
|
||||
if (file_exists('../test-settings.php')) include '../test-settings.php';
|
||||
|
||||
if (!$csstidy_location) {
|
||||
?>
|
||||
Error: <a href="http://csstidy.sourceforge.net/">CSSTidy</a> library not
|
||||
found, please install and configure <code>test-settings.php</code>
|
||||
accordingly.
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once $csstidy_location . 'class.csstidy.php';
|
||||
require_once $csstidy_location . 'class.csstidy_print.php';
|
||||
|
||||
$purifier = new HTMLPurifier(array(
|
||||
'Filter.ExtractStyleBlocks' => true,
|
||||
));
|
||||
|
@ -17,20 +17,6 @@ if ($data !== false && $data !== '') {
|
||||
exit;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// REQUIRED SETTINGS
|
||||
|
||||
// Note on running SimpleTest:
|
||||
// You want the Git copy of SimpleTest, found here:
|
||||
// https://github.com/simpletest/simpletest/
|
||||
//
|
||||
// If SimpleTest is borked with HTML Purifier, please contact me or
|
||||
// the SimpleTest devs; I am a developer for SimpleTest so I should be
|
||||
// able to quickly assess a fix. SimpleTest's problem is my problem!
|
||||
|
||||
// Where is SimpleTest located? Remember to include a trailing slash!
|
||||
$simpletest_location = '/path/to/simpletest/';
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// OPTIONAL SETTINGS
|
||||
|
||||
@ -50,9 +36,6 @@ $GLOBALS['HTMLPurifierTest']['PHPT'] = false;
|
||||
// If PHPT isn't in your Path via PEAR, set that here:
|
||||
// set_include_path('/path/to/phpt/Core/src' . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
// Where is CSSTidy located? (Include trailing slash. Leave false to disable.)
|
||||
$csstidy_location = false;
|
||||
|
||||
// For tests/multitest.php, which versions to test?
|
||||
$versions_to_test = array();
|
||||
|
||||
@ -69,6 +52,6 @@ $GLOBALS['HTMLPurifierTest']['PEAR'] = false;
|
||||
|
||||
// If PEAR is enabled, what PEAR tests should be run? (Note: you will
|
||||
// need to ensure these libraries are installed)
|
||||
$GLOBALS['HTMLPurifierTest']['Net_IDNA2'] = true;
|
||||
$GLOBALS['HTMLPurifierTest']['Net_IDNA2'] = false;
|
||||
|
||||
// vim: et sw=4 sts=4
|
||||
|
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
|
||||
// This file is the configuration for Travis testing.
|
||||
|
||||
// Note: The only external library you *need* is SimpleTest; everything else
|
||||
// is optional.
|
||||
|
||||
// We've got a lot of tests, so we recommend turning the limit off.
|
||||
set_time_limit(0);
|
||||
|
||||
// Turning off output buffering will prevent mysterious errors from core dumps.
|
||||
$data = @ob_get_clean();
|
||||
if ($data !== false && $data !== '') {
|
||||
echo "Output buffer contains data [".urlencode($data)."]\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// REQUIRED SETTINGS
|
||||
|
||||
// Note on running SimpleTest:
|
||||
// You want the Git copy of SimpleTest, found here:
|
||||
// https://github.com/simpletest/simpletest/
|
||||
//
|
||||
// If SimpleTest is borked with HTML Purifier, please contact me or
|
||||
// the SimpleTest devs; I am a developer for SimpleTest so I should be
|
||||
// able to quickly assess a fix. SimpleTest's problem is my problem!
|
||||
|
||||
// Where is SimpleTest located? Remember to include a trailing slash!
|
||||
$simpletest_location = dirname(__FILE__) . '/simpletest/';
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// OPTIONAL SETTINGS
|
||||
|
||||
// Note on running PHPT:
|
||||
// Vanilla PHPT from https://github.com/tswicegood/PHPT_Core should
|
||||
// work fine on Linux w/o multitest.
|
||||
//
|
||||
// To do multitest or Windows testing, you'll need some more
|
||||
// patches at https://github.com/ezyang/PHPT_Core
|
||||
//
|
||||
// I haven't tested the Windows setup in a while so I don't know if
|
||||
// it still works.
|
||||
|
||||
// Should PHPT tests be enabled?
|
||||
$GLOBALS['HTMLPurifierTest']['PHPT'] = false;
|
||||
|
||||
// If PHPT isn't in your Path via PEAR, set that here:
|
||||
// set_include_path('/path/to/phpt/Core/src' . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
// Where is CSSTidy located? (Include trailing slash. Leave false to disable.)
|
||||
$csstidy_location = false;
|
||||
|
||||
// For tests/multitest.php, which versions to test?
|
||||
$versions_to_test = array();
|
||||
|
||||
// Stable PHP binary to use when invoking maintenance scripts.
|
||||
$php = 'php';
|
||||
|
||||
// For tests/multitest.php, what is the multi-version executable? It must
|
||||
// accept an extra parameter (version number) before all other arguments
|
||||
$phpv = false;
|
||||
|
||||
// Should PEAR tests be run? If you've got a valid PEAR installation, set this
|
||||
// to true (or, if it's not in the include path, to its install directory).
|
||||
$GLOBALS['HTMLPurifierTest']['PEAR'] = false;
|
||||
|
||||
// If PEAR is enabled, what PEAR tests should be run? (Note: you will
|
||||
// need to ensure these libraries are installed)
|
||||
$GLOBALS['HTMLPurifierTest']['Net_IDNA2'] = true;
|
||||
|
||||
// vim: et sw=4 sts=4
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
if (!defined('HTMLPurifierTest')) {
|
||||
echo "Invalid entry point\n";
|
||||
exit;
|
||||
@ -27,8 +29,6 @@ $GLOBALS['HTMLPurifierTest']['PHPT'] = true; // do PHPT tests
|
||||
$GLOBALS['HTMLPurifierTest']['PH5P'] = class_exists('DOMDocument');
|
||||
|
||||
// default library settings
|
||||
$simpletest_location = 'simpletest/'; // reasonable guess
|
||||
$csstidy_location = false;
|
||||
$versions_to_test = array();
|
||||
$php = 'php';
|
||||
$phpv = 'phpv';
|
||||
@ -40,20 +40,6 @@ else {
|
||||
throw new Exception('Please create a test-settings.php file by copying test-settings.sample.php and configuring accordingly');
|
||||
}
|
||||
|
||||
// load SimpleTest
|
||||
require_once $simpletest_location . 'unit_tester.php';
|
||||
require_once $simpletest_location . 'reporter.php';
|
||||
require_once $simpletest_location . 'mock_objects.php';
|
||||
require_once $simpletest_location . 'xml.php';
|
||||
require_once $simpletest_location . 'remote.php';
|
||||
|
||||
// load CSS Tidy
|
||||
if ($csstidy_location !== false) {
|
||||
$old = error_reporting(E_ALL);
|
||||
require $csstidy_location . 'class.csstidy.php';
|
||||
error_reporting($old);
|
||||
}
|
||||
|
||||
// load PEAR to include path
|
||||
if ( is_string($GLOBALS['HTMLPurifierTest']['PEAR']) ) {
|
||||
// if PEAR is true, there's no need to add it to the path
|
||||
|
@ -18,9 +18,7 @@ switch ($AC['type']) {
|
||||
$test_dirs[] = 'HTMLPurifier';
|
||||
$test_files[] = 'HTMLPurifierTest.php';
|
||||
$test_dirs_exclude['HTMLPurifier/Filter/ExtractStyleBlocksTest.php'] = true;
|
||||
if ($csstidy_location) {
|
||||
$test_files[] = 'HTMLPurifier/Filter/ExtractStyleBlocksTest.php';
|
||||
}
|
||||
$test_files[] = 'HTMLPurifier/Filter/ExtractStyleBlocksTest.php';
|
||||
if ($break) break;
|
||||
case 'configdoc':
|
||||
if (version_compare(PHP_VERSION, '5.2', '>=')) {
|
||||
|
Loading…
Reference in New Issue
Block a user