mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-22 00:11:52 +00:00
Update PHPT instructions.
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
parent
cfc4ee1faf
commit
6dcc37cb55
@ -1,367 +0,0 @@
|
||||
Index: src/PHPT/Case.php
|
||||
===================================================================
|
||||
--- src/PHPT/Case.php (revision 691)
|
||||
+++ src/PHPT/Case.php (working copy)
|
||||
@@ -28,17 +28,14 @@
|
||||
{
|
||||
$reporter->onCaseStart($this);
|
||||
try {
|
||||
- if ($this->sections->filterByInterface('RunnableBefore')->valid()) {
|
||||
- foreach ($this->sections as $section) {
|
||||
- $section->run($this);
|
||||
- }
|
||||
+ $runnable_before = $this->sections->filterByInterface('RunnableBefore');
|
||||
+ foreach ($runnable_before as $section) {
|
||||
+ $section->run($this);
|
||||
}
|
||||
- $this->sections->filterByInterface();
|
||||
$this->sections->FILE->run($this);
|
||||
- if ($this->sections->filterByInterface('RunnableAfter')->valid()) {
|
||||
- foreach ($this->sections as $section) {
|
||||
- $section->run($this);
|
||||
- }
|
||||
+ $runnable_after = $this->sections->filterByInterface('RunnableAfter');
|
||||
+ foreach ($runnable_after as $section) {
|
||||
+ $section->run($this);
|
||||
}
|
||||
$reporter->onCasePass($this);
|
||||
} catch (PHPT_Case_VetoException $veto) {
|
||||
@@ -46,7 +43,6 @@
|
||||
} catch (PHPT_Case_FailureException $failure) {
|
||||
$reporter->onCaseFail($this, $failure);
|
||||
}
|
||||
- $this->sections->filterByInterface();
|
||||
$reporter->onCaseEnd($this);
|
||||
}
|
||||
|
||||
Index: src/PHPT/Case/Validator/CgiRequired.php
|
||||
===================================================================
|
||||
--- src/PHPT/Case/Validator/CgiRequired.php (revision 691)
|
||||
+++ src/PHPT/Case/Validator/CgiRequired.php (working copy)
|
||||
@@ -17,7 +17,6 @@
|
||||
public function is(PHPT_Case $case)
|
||||
{
|
||||
$return = $case->sections->filterByInterface('CgiExecutable')->valid();
|
||||
- $case->sections->filterByInterface();
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
Index: src/PHPT/CodeRunner/CommandLine.php
|
||||
===================================================================
|
||||
--- src/PHPT/CodeRunner/CommandLine.php (revision 691)
|
||||
+++ src/PHPT/CodeRunner/CommandLine.php (working copy)
|
||||
@@ -13,7 +13,7 @@
|
||||
$this->_filename = $runner->filename;
|
||||
$this->_ini = (string)$runner->ini;
|
||||
$this->_args = (string)$runner->args;
|
||||
- $this->_executable = str_replace(' ', '\ ', (string)$runner->executable);
|
||||
+ $this->_executable = $runner->executable;
|
||||
$this->_post_filename = (string)$runner->post_filename;
|
||||
}
|
||||
|
||||
Index: src/PHPT/CodeRunner/Driver/WScriptShell.php
|
||||
===================================================================
|
||||
--- src/PHPT/CodeRunner/Driver/WScriptShell.php (revision 691)
|
||||
+++ src/PHPT/CodeRunner/Driver/WScriptShell.php (working copy)
|
||||
@@ -23,9 +23,9 @@
|
||||
}
|
||||
}
|
||||
if ($found == false) {
|
||||
- throw new PHPT_CodeRunner_InvalidExecutableException(
|
||||
- 'unable to locate PHP executable: ' . $this->executable
|
||||
- );
|
||||
+ //throw new PHPT_CodeRunner_InvalidExecutableException(
|
||||
+ // 'unable to locate PHP executable: ' . $this->executable
|
||||
+ //);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
$error = $this->_process->StdErr->ReadAll();
|
||||
if (!empty($error)) {
|
||||
- throw new PHPT_CodeRunner_ExecutionException($error);
|
||||
+ throw new PHPT_CodeRunner_ExecutionException($error, $this->_commandFactory());
|
||||
}
|
||||
|
||||
return $this->_process->StdOut->ReadAll();
|
||||
@@ -93,6 +93,7 @@
|
||||
{
|
||||
$return = '';
|
||||
foreach ($this->environment as $key => $value) {
|
||||
+ $value = str_replace('&', '^&', $value);
|
||||
$return .= "set {$key}={$value} & ";
|
||||
}
|
||||
return $return;
|
||||
Index: src/PHPT/CodeRunner/Factory.php
|
||||
===================================================================
|
||||
--- src/PHPT/CodeRunner/Factory.php (revision 691)
|
||||
+++ src/PHPT/CodeRunner/Factory.php (working copy)
|
||||
@@ -33,7 +33,13 @@
|
||||
'php-cgi';
|
||||
}
|
||||
|
||||
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||
+ if (
|
||||
+ strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' &&
|
||||
+ (
|
||||
+ $runner->executable == 'php' ||
|
||||
+ $runner->executable == 'php-cgi'
|
||||
+ )
|
||||
+ ) {
|
||||
$runner->executable = $runner->executable . '.exe';
|
||||
}
|
||||
try {
|
||||
Index: src/PHPT/Section/ModifiableAbstract.php
|
||||
===================================================================
|
||||
--- src/PHPT/Section/ModifiableAbstract.php (revision 691)
|
||||
+++ src/PHPT/Section/ModifiableAbstract.php (working copy)
|
||||
@@ -15,12 +15,10 @@
|
||||
|
||||
public function run(PHPT_Case $case)
|
||||
{
|
||||
- $sections = clone $case->sections;
|
||||
- if ($sections->filterByInterface($this->_modifier_name . 'Modifier')->valid()) {
|
||||
- $modifyMethod = 'modify' . $this->_modifier_name;
|
||||
- foreach ($sections as $section) {
|
||||
- $section->$modifyMethod($this);
|
||||
- }
|
||||
+ $modifiers = $case->sections->filterByInterface($this->_modifier_name . 'Modifier');
|
||||
+ $modifyMethod = 'modify' . $this->_modifier_name;
|
||||
+ foreach ($modifiers as $section) {
|
||||
+ $section->$modifyMethod($this);
|
||||
}
|
||||
}
|
||||
|
||||
Index: src/PHPT/Section/SKIPIF.php
|
||||
===================================================================
|
||||
--- src/PHPT/Section/SKIPIF.php (revision 691)
|
||||
+++ src/PHPT/Section/SKIPIF.php (working copy)
|
||||
@@ -3,10 +3,12 @@
|
||||
class PHPT_Section_SKIPIF implements PHPT_Section_RunnableBefore
|
||||
{
|
||||
private $_data = null;
|
||||
+ private $_runner_factory = null;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->_data = $data;
|
||||
+ $this->_runner_factory = new PHPT_CodeRunner_Factory();
|
||||
}
|
||||
|
||||
public function run(PHPT_Case $case)
|
||||
@@ -16,9 +18,7 @@
|
||||
|
||||
// @todo refactor to PHPT_CodeRunner
|
||||
file_put_contents($filename, $this->_data);
|
||||
- $response = array();
|
||||
- exec('php -f ' . $filename, $response);
|
||||
- $response = implode("\n", $response);
|
||||
+ $response = $this->_runner_factory->factory($case)->run($filename)->output;
|
||||
unlink($filename);
|
||||
|
||||
if (preg_match('/^skip( - (.*))?/', $response, $matches)) {
|
||||
Index: src/PHPT/SectionList.php
|
||||
===================================================================
|
||||
--- src/PHPT/SectionList.php (revision 691)
|
||||
+++ src/PHPT/SectionList.php (working copy)
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
class PHPT_SectionList implements Iterator
|
||||
{
|
||||
- private $_raw_sections = array();
|
||||
private $_sections = array();
|
||||
private $_section_map = array();
|
||||
private $_key_map = array();
|
||||
@@ -15,14 +14,12 @@
|
||||
}
|
||||
$name = strtoupper(str_replace('PHPT_Section_', '', get_class($section)));
|
||||
$key = $section instanceof PHPT_Section_Runnable ? $section->getPriority() . '.' . $name : $name;
|
||||
- $this->_raw_sections[$key] = $section;
|
||||
+ $this->_sections[$key] = $section;
|
||||
$this->_section_map[$name] = $key;
|
||||
$this->_key_map[$key] = $name;
|
||||
}
|
||||
|
||||
- ksort($this->_raw_sections);
|
||||
-
|
||||
- $this->_sections = $this->_raw_sections;
|
||||
+ ksort($this->_sections);
|
||||
}
|
||||
|
||||
public function current()
|
||||
@@ -52,21 +49,23 @@
|
||||
|
||||
public function filterByInterface($interface = null)
|
||||
{
|
||||
+ $ret = new PHPT_SectionList();
|
||||
+
|
||||
if (is_null($interface)) {
|
||||
- $this->_sections = $this->_raw_sections;
|
||||
- return $this;
|
||||
+ $ret->_sections = $this->_sections;
|
||||
+ return $ret;
|
||||
}
|
||||
|
||||
$full_interface = 'PHPT_Section_' . $interface;
|
||||
- $this->_sections = array();
|
||||
- foreach ($this->_raw_sections as $name => $section) {
|
||||
+ $ret->_sections = array();
|
||||
+ foreach ($this->_sections as $name => $section) {
|
||||
if (!$section instanceof $full_interface) {
|
||||
continue;
|
||||
}
|
||||
- $this->_sections[$name] = $section;
|
||||
+ $ret->_sections[$name] = $section;
|
||||
}
|
||||
|
||||
- return $this;
|
||||
+ return $ret;
|
||||
}
|
||||
|
||||
public function has($name)
|
||||
@@ -74,11 +73,11 @@
|
||||
if (!isset($this->_section_map[$name])) {
|
||||
return false;
|
||||
}
|
||||
- return isset($this->_raw_sections[$this->_section_map[$name]]);
|
||||
+ return isset($this->_sections[$this->_section_map[$name]]);
|
||||
}
|
||||
|
||||
public function __get($key)
|
||||
{
|
||||
- return $this->_raw_sections[$this->_section_map[$key]];
|
||||
+ return $this->_sections[$this->_section_map[$key]];
|
||||
}
|
||||
}
|
||||
Index: tests/CodeRunner/Driver/WScriptShell/injects-ini-settings.phpt
|
||||
===================================================================
|
||||
--- tests/CodeRunner/Driver/WScriptShell/injects-ini-settings.phpt (revision 691)
|
||||
+++ tests/CodeRunner/Driver/WScriptShell/injects-ini-settings.phpt (working copy)
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
// sanity check
|
||||
$obj = new FoobarIni();
|
||||
-assert('(string)$obj == " -d display_errors=1 "');
|
||||
+assert('(string)$obj == " -d \"display_errors=1\" "');
|
||||
$obj->display_errors = 0;
|
||||
-assert('(string)$obj == " -d display_errors=0 "');
|
||||
+assert('(string)$obj == " -d \"display_errors=0\" "');
|
||||
unset($obj);
|
||||
|
||||
|
||||
Index: tests/Section/File/restores-case-sections.phpt
|
||||
===================================================================
|
||||
--- tests/Section/File/restores-case-sections.phpt (revision 691)
|
||||
+++ tests/Section/File/restores-case-sections.phpt (working copy)
|
||||
@@ -1,24 +0,0 @@
|
||||
---TEST--
|
||||
-After PHPT_Section_FILE::run(), the sections property of the provide $case object
|
||||
-is restored to its unfiltered state
|
||||
---FILE--
|
||||
-<?php
|
||||
-
|
||||
-require_once dirname(__FILE__) . '/../../_setup.inc';
|
||||
-require_once dirname(__FILE__) . '/../_simple-test-case.inc';
|
||||
-require_once dirname(__FILE__) . '/_simple-file-modifier.inc';
|
||||
-
|
||||
-$case = new PHPT_SimpleTestCase();
|
||||
-$case->sections = new PHPT_SectionList(array(
|
||||
- new PHPT_Section_ARGS('foo=bar'),
|
||||
-));
|
||||
-
|
||||
-$section = new PHPT_Section_FILE('hello world');
|
||||
-$section->run($case);
|
||||
-
|
||||
-assert('$case->sections->valid()');
|
||||
-
|
||||
-?>
|
||||
-===DONE===
|
||||
---EXPECT--
|
||||
-===DONE===
|
||||
Index: tests/SectionList/filter-by-interface.phpt
|
||||
===================================================================
|
||||
--- tests/SectionList/filter-by-interface.phpt (revision 691)
|
||||
+++ tests/SectionList/filter-by-interface.phpt (working copy)
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
$data = array_merge($runnable, $non_runnable);
|
||||
$list = new PHPT_SectionList($data);
|
||||
-$list->filterByInterface('Runnable');
|
||||
-assert('$list->valid()');
|
||||
-$list->filterByInterface('EnvModifier');
|
||||
-assert('$list->valid() == false');
|
||||
+$runnable = $list->filterByInterface('Runnable');
|
||||
+assert('$runnable->valid()');
|
||||
+$env_modifier = $list->filterByInterface('EnvModifier');
|
||||
+assert('$env_modifier->valid() == false');
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
Index: tests/SectionList/filter-resets-with-null.phpt
|
||||
===================================================================
|
||||
--- tests/SectionList/filter-resets-with-null.phpt (revision 691)
|
||||
+++ tests/SectionList/filter-resets-with-null.phpt (working copy)
|
||||
@@ -1,36 +0,0 @@
|
||||
---TEST--
|
||||
-If you call filterByInterface() with null or no-value, the full dataset is restored
|
||||
---FILE--
|
||||
-<?php
|
||||
-
|
||||
-require_once dirname(__FILE__) . '/../_setup.inc';
|
||||
-
|
||||
-$runnable = array(
|
||||
- 'ENV' => new PHPT_Section_ENV(''),
|
||||
- 'CLEAN' => new PHPT_Section_CLEAN(''),
|
||||
-);
|
||||
-
|
||||
-class PHPT_Section_FOO implements PHPT_Section { }
|
||||
-$non_runnable = array(
|
||||
- 'FOO' => new PHPT_Section_FOO(),
|
||||
-);
|
||||
-
|
||||
-$data = array_merge($runnable, $non_runnable);
|
||||
-$list = new PHPT_SectionList($data);
|
||||
-$list->filterByInterface('Runnable');
|
||||
-
|
||||
-// sanity check
|
||||
-foreach ($list as $key => $value) {
|
||||
- assert('$runnable[$key] == $value');
|
||||
-}
|
||||
-
|
||||
-$list->filterByInterface();
|
||||
-
|
||||
-foreach ($list as $key => $value) {
|
||||
- assert('$data[$key] == $value');
|
||||
-}
|
||||
-
|
||||
-?>
|
||||
-===DONE===
|
||||
---EXPECT--
|
||||
-===DONE===
|
||||
Index: tests/Util/Code/runAsFile-executes-in-file.phpt
|
||||
===================================================================
|
||||
--- tests/Util/Code/runAsFile-executes-in-file.phpt (revision 691)
|
||||
+++ tests/Util/Code/runAsFile-executes-in-file.phpt (working copy)
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
$util = new PHPT_Util_Code($code);
|
||||
|
||||
-$file = dirname(__FILE__) . '/foobar.php';
|
||||
+$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foobar.php';
|
||||
$result = $util->runAsFile($file);
|
||||
|
||||
assert('$result == $file');
|
||||
Index: tests/Util/Code/runAsFile-returns-output-if-no-return.phpt
|
||||
===================================================================
|
||||
--- tests/Util/Code/runAsFile-returns-output-if-no-return.phpt (revision 691)
|
||||
+++ tests/Util/Code/runAsFile-returns-output-if-no-return.phpt (working copy)
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
$util = new PHPT_Util_Code($code);
|
||||
|
||||
-$file = dirname(__FILE__) . '/foobar.php';
|
||||
+$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foobar.php';
|
||||
$result = $util->runAsFile($file);
|
||||
|
||||
assert('$result == $file');
|
@ -37,13 +37,14 @@ $simpletest_location = '/path/to/simpletest/';
|
||||
// OPTIONAL SETTINGS
|
||||
|
||||
// Note on running PHPT:
|
||||
// Vanilla PHPT from http://phpt.info will not work, because there are
|
||||
// a number of bugs that prevent HTML Purifier from doing what they need
|
||||
// to do. If you really want to run PHPT, you'll will need to apply the
|
||||
// patches in maintenance/phpt-modifications.patch on the PHPT Core trunk,
|
||||
// which can be checked out using:
|
||||
// Vanilla PHPT from https://github.com/tswicegood/PHPT_Core should
|
||||
// work fine on Linux w/o multitest.
|
||||
//
|
||||
// $ svn co https://svn.phpt.info/Core/trunk phpt-core
|
||||
// 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;
|
||||
|
Loading…
Reference in New Issue
Block a user