Fix newline issues in tests.
[htmlpurifier/darkodev.git] / maintenance / phpt-modifications.patch
blob4d135dc6c05bc28b3374158f395b4e403d4b457d
1 Index: src/PHPT/Case.php
2 ===================================================================
3 --- src/PHPT/Case.php (revision 691)
4 +++ src/PHPT/Case.php (working copy)
5 @@ -28,17 +28,14 @@
7 $reporter->onCaseStart($this);
8 try {
9 - if ($this->sections->filterByInterface('RunnableBefore')->valid()) {
10 - foreach ($this->sections as $section) {
11 - $section->run($this);
12 - }
13 + $runnable_before = $this->sections->filterByInterface('RunnableBefore');
14 + foreach ($runnable_before as $section) {
15 + $section->run($this);
17 - $this->sections->filterByInterface();
18 $this->sections->FILE->run($this);
19 - if ($this->sections->filterByInterface('RunnableAfter')->valid()) {
20 - foreach ($this->sections as $section) {
21 - $section->run($this);
22 - }
23 + $runnable_after = $this->sections->filterByInterface('RunnableAfter');
24 + foreach ($runnable_after as $section) {
25 + $section->run($this);
27 $reporter->onCasePass($this);
28 } catch (PHPT_Case_VetoException $veto) {
29 @@ -46,7 +43,6 @@
30 } catch (PHPT_Case_FailureException $failure) {
31 $reporter->onCaseFail($this, $failure);
33 - $this->sections->filterByInterface();
34 $reporter->onCaseEnd($this);
37 Index: src/PHPT/Case/Validator/CgiRequired.php
38 ===================================================================
39 --- src/PHPT/Case/Validator/CgiRequired.php (revision 691)
40 +++ src/PHPT/Case/Validator/CgiRequired.php (working copy)
41 @@ -17,7 +17,6 @@
42 public function is(PHPT_Case $case)
44 $return = $case->sections->filterByInterface('CgiExecutable')->valid();
45 - $case->sections->filterByInterface();
46 return $return;
49 Index: src/PHPT/CodeRunner/CommandLine.php
50 ===================================================================
51 --- src/PHPT/CodeRunner/CommandLine.php (revision 691)
52 +++ src/PHPT/CodeRunner/CommandLine.php (working copy)
53 @@ -13,7 +13,7 @@
54 $this->_filename = $runner->filename;
55 $this->_ini = (string)$runner->ini;
56 $this->_args = (string)$runner->args;
57 - $this->_executable = str_replace(' ', '\ ', (string)$runner->executable);
58 + $this->_executable = $runner->executable;
59 $this->_post_filename = (string)$runner->post_filename;
62 Index: src/PHPT/CodeRunner/Driver/WScriptShell.php
63 ===================================================================
64 --- src/PHPT/CodeRunner/Driver/WScriptShell.php (revision 691)
65 +++ src/PHPT/CodeRunner/Driver/WScriptShell.php (working copy)
66 @@ -23,9 +23,9 @@
69 if ($found == false) {
70 - throw new PHPT_CodeRunner_InvalidExecutableException(
71 - 'unable to locate PHP executable: ' . $this->executable
72 - );
73 + //throw new PHPT_CodeRunner_InvalidExecutableException(
74 + // 'unable to locate PHP executable: ' . $this->executable
75 + //);
79 @@ -69,7 +69,7 @@
81 $error = $this->_process->StdErr->ReadAll();
82 if (!empty($error)) {
83 - throw new PHPT_CodeRunner_ExecutionException($error);
84 + throw new PHPT_CodeRunner_ExecutionException($error, $this->_commandFactory());
87 return $this->_process->StdOut->ReadAll();
88 @@ -93,6 +93,7 @@
90 $return = '';
91 foreach ($this->environment as $key => $value) {
92 + $value = str_replace('&', '^&', $value);
93 $return .= "set {$key}={$value} & ";
95 return $return;
96 Index: src/PHPT/CodeRunner/Factory.php
97 ===================================================================
98 --- src/PHPT/CodeRunner/Factory.php (revision 691)
99 +++ src/PHPT/CodeRunner/Factory.php (working copy)
100 @@ -33,7 +33,13 @@
101 'php-cgi';
104 - if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
105 + if (
106 + strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' &&
108 + $runner->executable == 'php' ||
109 + $runner->executable == 'php-cgi'
111 + ) {
112 $runner->executable = $runner->executable . '.exe';
114 try {
115 Index: src/PHPT/Section/ModifiableAbstract.php
116 ===================================================================
117 --- src/PHPT/Section/ModifiableAbstract.php (revision 691)
118 +++ src/PHPT/Section/ModifiableAbstract.php (working copy)
119 @@ -15,12 +15,10 @@
121 public function run(PHPT_Case $case)
123 - $sections = clone $case->sections;
124 - if ($sections->filterByInterface($this->_modifier_name . 'Modifier')->valid()) {
125 - $modifyMethod = 'modify' . $this->_modifier_name;
126 - foreach ($sections as $section) {
127 - $section->$modifyMethod($this);
129 + $modifiers = $case->sections->filterByInterface($this->_modifier_name . 'Modifier');
130 + $modifyMethod = 'modify' . $this->_modifier_name;
131 + foreach ($modifiers as $section) {
132 + $section->$modifyMethod($this);
136 Index: src/PHPT/Section/SKIPIF.php
137 ===================================================================
138 --- src/PHPT/Section/SKIPIF.php (revision 691)
139 +++ src/PHPT/Section/SKIPIF.php (working copy)
140 @@ -3,10 +3,12 @@
141 class PHPT_Section_SKIPIF implements PHPT_Section_RunnableBefore
143 private $_data = null;
144 + private $_runner_factory = null;
146 public function __construct($data)
148 $this->_data = $data;
149 + $this->_runner_factory = new PHPT_CodeRunner_Factory();
152 public function run(PHPT_Case $case)
153 @@ -16,9 +18,7 @@
155 // @todo refactor to PHPT_CodeRunner
156 file_put_contents($filename, $this->_data);
157 - $response = array();
158 - exec('php -f ' . $filename, $response);
159 - $response = implode("\n", $response);
160 + $response = $this->_runner_factory->factory($case)->run($filename)->output;
161 unlink($filename);
163 if (preg_match('/^skip( - (.*))?/', $response, $matches)) {
164 Index: src/PHPT/SectionList.php
165 ===================================================================
166 --- src/PHPT/SectionList.php (revision 691)
167 +++ src/PHPT/SectionList.php (working copy)
168 @@ -2,7 +2,6 @@
170 class PHPT_SectionList implements Iterator
172 - private $_raw_sections = array();
173 private $_sections = array();
174 private $_section_map = array();
175 private $_key_map = array();
176 @@ -15,14 +14,12 @@
178 $name = strtoupper(str_replace('PHPT_Section_', '', get_class($section)));
179 $key = $section instanceof PHPT_Section_Runnable ? $section->getPriority() . '.' . $name : $name;
180 - $this->_raw_sections[$key] = $section;
181 + $this->_sections[$key] = $section;
182 $this->_section_map[$name] = $key;
183 $this->_key_map[$key] = $name;
186 - ksort($this->_raw_sections);
188 - $this->_sections = $this->_raw_sections;
189 + ksort($this->_sections);
192 public function current()
193 @@ -52,21 +49,23 @@
195 public function filterByInterface($interface = null)
197 + $ret = new PHPT_SectionList();
199 if (is_null($interface)) {
200 - $this->_sections = $this->_raw_sections;
201 - return $this;
202 + $ret->_sections = $this->_sections;
203 + return $ret;
206 $full_interface = 'PHPT_Section_' . $interface;
207 - $this->_sections = array();
208 - foreach ($this->_raw_sections as $name => $section) {
209 + $ret->_sections = array();
210 + foreach ($this->_sections as $name => $section) {
211 if (!$section instanceof $full_interface) {
212 continue;
214 - $this->_sections[$name] = $section;
215 + $ret->_sections[$name] = $section;
218 - return $this;
219 + return $ret;
222 public function has($name)
223 @@ -74,11 +73,11 @@
224 if (!isset($this->_section_map[$name])) {
225 return false;
227 - return isset($this->_raw_sections[$this->_section_map[$name]]);
228 + return isset($this->_sections[$this->_section_map[$name]]);
231 public function __get($key)
233 - return $this->_raw_sections[$this->_section_map[$key]];
234 + return $this->_sections[$this->_section_map[$key]];
237 Index: tests/CodeRunner/Driver/WScriptShell/injects-ini-settings.phpt
238 ===================================================================
239 --- tests/CodeRunner/Driver/WScriptShell/injects-ini-settings.phpt (revision 691)
240 +++ tests/CodeRunner/Driver/WScriptShell/injects-ini-settings.phpt (working copy)
241 @@ -17,9 +17,9 @@
243 // sanity check
244 $obj = new FoobarIni();
245 -assert('(string)$obj == " -d display_errors=1 "');
246 +assert('(string)$obj == " -d \"display_errors=1\" "');
247 $obj->display_errors = 0;
248 -assert('(string)$obj == " -d display_errors=0 "');
249 +assert('(string)$obj == " -d \"display_errors=0\" "');
250 unset($obj);
253 Index: tests/Section/File/restores-case-sections.phpt
254 ===================================================================
255 --- tests/Section/File/restores-case-sections.phpt (revision 691)
256 +++ tests/Section/File/restores-case-sections.phpt (working copy)
257 @@ -1,24 +0,0 @@
258 ---TEST--
259 -After PHPT_Section_FILE::run(), the sections property of the provide $case object
260 -is restored to its unfiltered state
261 ---FILE--
262 -<?php
264 -require_once dirname(__FILE__) . '/../../_setup.inc';
265 -require_once dirname(__FILE__) . '/../_simple-test-case.inc';
266 -require_once dirname(__FILE__) . '/_simple-file-modifier.inc';
268 -$case = new PHPT_SimpleTestCase();
269 -$case->sections = new PHPT_SectionList(array(
270 - new PHPT_Section_ARGS('foo=bar'),
271 -));
273 -$section = new PHPT_Section_FILE('hello world');
274 -$section->run($case);
276 -assert('$case->sections->valid()');
279 -===DONE===
280 ---EXPECT--
281 -===DONE===
282 Index: tests/SectionList/filter-by-interface.phpt
283 ===================================================================
284 --- tests/SectionList/filter-by-interface.phpt (revision 691)
285 +++ tests/SectionList/filter-by-interface.phpt (working copy)
286 @@ -17,10 +17,10 @@
288 $data = array_merge($runnable, $non_runnable);
289 $list = new PHPT_SectionList($data);
290 -$list->filterByInterface('Runnable');
291 -assert('$list->valid()');
292 -$list->filterByInterface('EnvModifier');
293 -assert('$list->valid() == false');
294 +$runnable = $list->filterByInterface('Runnable');
295 +assert('$runnable->valid()');
296 +$env_modifier = $list->filterByInterface('EnvModifier');
297 +assert('$env_modifier->valid() == false');
300 ===DONE===
301 Index: tests/SectionList/filter-resets-with-null.phpt
302 ===================================================================
303 --- tests/SectionList/filter-resets-with-null.phpt (revision 691)
304 +++ tests/SectionList/filter-resets-with-null.phpt (working copy)
305 @@ -1,36 +0,0 @@
306 ---TEST--
307 -If you call filterByInterface() with null or no-value, the full dataset is restored
308 ---FILE--
309 -<?php
311 -require_once dirname(__FILE__) . '/../_setup.inc';
313 -$runnable = array(
314 - 'ENV' => new PHPT_Section_ENV(''),
315 - 'CLEAN' => new PHPT_Section_CLEAN(''),
318 -class PHPT_Section_FOO implements PHPT_Section { }
319 -$non_runnable = array(
320 - 'FOO' => new PHPT_Section_FOO(),
323 -$data = array_merge($runnable, $non_runnable);
324 -$list = new PHPT_SectionList($data);
325 -$list->filterByInterface('Runnable');
327 -// sanity check
328 -foreach ($list as $key => $value) {
329 - assert('$runnable[$key] == $value');
332 -$list->filterByInterface();
334 -foreach ($list as $key => $value) {
335 - assert('$data[$key] == $value');
339 -===DONE===
340 ---EXPECT--
341 -===DONE===
342 Index: tests/Util/Code/runAsFile-executes-in-file.phpt
343 ===================================================================
344 --- tests/Util/Code/runAsFile-executes-in-file.phpt (revision 691)
345 +++ tests/Util/Code/runAsFile-executes-in-file.phpt (working copy)
346 @@ -10,7 +10,7 @@
348 $util = new PHPT_Util_Code($code);
350 -$file = dirname(__FILE__) . '/foobar.php';
351 +$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foobar.php';
352 $result = $util->runAsFile($file);
354 assert('$result == $file');
355 Index: tests/Util/Code/runAsFile-returns-output-if-no-return.phpt
356 ===================================================================
357 --- tests/Util/Code/runAsFile-returns-output-if-no-return.phpt (revision 691)
358 +++ tests/Util/Code/runAsFile-returns-output-if-no-return.phpt (working copy)
359 @@ -9,7 +9,7 @@
361 $util = new PHPT_Util_Code($code);
363 -$file = dirname(__FILE__) . '/foobar.php';
364 +$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foobar.php';
365 $result = $util->runAsFile($file);
367 assert('$result == $file');