Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run CSSTidy tests on CI #338

Merged
merged 7 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 14 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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 changes: 2 additions & 0 deletions smoketests/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 0 additions & 17 deletions smoketests/extractStyleBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
));
Expand Down
19 changes: 1 addition & 18 deletions test-settings.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,6 @@
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

Expand All @@ -50,9 +36,6 @@
// 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();

Expand All @@ -69,6 +52,6 @@

// 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
72 changes: 0 additions & 72 deletions test-settings.travis.php

This file was deleted.

18 changes: 2 additions & 16 deletions tests/common.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

require_once __DIR__.'/../vendor/autoload.php';

if (!defined('HTMLPurifierTest')) {
echo "Invalid entry point\n";
exit;
Expand Down Expand Up @@ -27,8 +29,6 @@ function test_autoload($class)
$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';
Expand All @@ -40,20 +40,6 @@ function test_autoload($class)
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
Expand Down
4 changes: 1 addition & 3 deletions tests/test_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
$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', '>=')) {
Expand Down