Skip to content
Browse files

Testing :

- give the url to PEAR Text Diff and simpletest that works for unit testing
- ignore 'deprecated' as PEAR Text diff as a lot of it
- test results is a var_export of expected result. Evaluate it and compare to real result os more robust than comparing var_export
that can give false negative results due to extra space in php representation of array.

2 test fails at this step
  • Loading branch information...
1 parent 9ba03a1 commit e9ce69e8482a3952bd21ffede3fb9fd6e9f8abca @Cerdic committed
Showing with 18 additions and 10 deletions.
  1. +1 −0 .gitignore
  2. +6 −1 testing/unit-tests.php
  3. +11 −9 testing/unit-tests/class.csstidy_csst.php
View
1 .gitignore
@@ -1,2 +1,3 @@
testing/simpletest*
testing/Text*
+nbproject*
View
7 testing/unit-tests.php
@@ -4,9 +4,14 @@
* Script for unit testing, allows for more fine grained error reporting
* when things go wrong.
* @author Edward Z. Yang <admin@htmlpurifier.org>
+ *
+ * Required
+ * unit-tets/Text : http://download.pear.php.net/package/Text_Diff-1.1.1.tgz
+ * unit-tests/simpletest/ : http://downloads.sourceforge.net/project/simpletest/simpletest/simpletest_1.0.1/simpletest_1.0.1.tar.gz?r=&ts=1289748853&use_mirror=freefr
+ *
*/
-error_reporting(E_ALL);
+error_reporting(E_ALL ^ E_DEPRECATED);
// Configuration
$simpletest_location = 'simpletest/';
View
20 testing/unit-tests/class.csstidy_csst.php
@@ -63,7 +63,9 @@ function load($filename) {
break;
}
}
- $this->expect = trim($this->expect, "\n"); // trim trailing/leading newlines
+ $this->expect = eval("return ".$this->expect.";");
+ if (!$this->fullexpect)
+ $this->expect = array(41=>$this->expect);
fclose($fh);
}
@@ -76,13 +78,7 @@ function test($filename = false) {
$css = new csstidy();
$css->set_cfg($this->settings);
$css->parse($this->css);
- if ($this->fullexpect) {
- $this->actual = var_export($css->css, true);
- } elseif (isset($css->css[41])) {
- $this->actual = var_export($css->css[41], true);
- } else {
- $this->actual = 'Key 41 does not exist';
- }
+ $this->actual = $css->css;
return $this->expect === $this->actual;
}
@@ -99,7 +95,13 @@ function testMessage() {
*/
function render() {
$message = '<pre>'. htmlspecialchars($this->css) .'</pre>';
- $diff = new Text_Diff('auto', array(explode("\n", $this->expect), explode("\n", $this->actual)));
+ $diff = new Text_Diff(
+ 'auto',
+ array(
+ explode("\n", var_export($this->expect,true)),
+ explode("\n", var_export($this->actual,true))
+ )
+ );
$renderer = new Text_Diff_Renderer_parallel();
$renderer->original = 'Expected';
$renderer->final = 'Actual';

0 comments on commit e9ce69e

Please sign in to comment.
Something went wrong with that request. Please try again.