Re: PHPUnit with OutputTestCase

From: Date: Sun, 08 Jul 2007 14:28:43 +0000
Subject: Re: PHPUnit with OutputTestCase
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-47271@lists.php.net to get a copy of this message
Laurent Laville a écrit :
Laurent Laville a écrit :
Hi PHPUnit testers, I want to know if someone has already used the OutputTestCase extension to check if a full html page is equal to an expected result. I would like to use it to PEAR_Info Test Suite, but i'm not sure if it's the best solution, and also if there is not a problem with long content. While I try the guide example [1], all work fine with PHPUnit 3.1.2, but when I used it with a long content , I always a failure while I pretty sure to have both content (expected, and printed) equals. Feedback are welcome Laurent [1] http://www.phpunit.de/pocket_guide/3.1/en/testcase-extensions.html#testcase-extensions.output
Well, I suspect a new bug with PHPUnit 3.1.2
Finally I found the problem, with xdebug, and traces ! Under some condition it work good, but if you want to compare a full html page then you reach : --> PHPUnit\Framework\Constraint\IsEqual.php:220
                return ($a == $b);
That return FALSE with $a = expected html result, and $b = actual html output (return by ob_get_contents) To verify my idea, I've wrote a little script : <?php $exp = file_get_contents('c:\php\pear\pear_info\tests\templates\general.exp'); $out = file_get_contents('c:\php\pear\pear_info\tests\templates\general.out'); if ($exp == $out) { print "test 1. equal"; } else { print "test 1. diff"; } print "<br/>\n"; if (strip_tags($exp) == strip_tags($out)) { print "test 2. equal"; } else { print "test 2. diff"; } ?> Where $exp is the html output expected and $out the real result (ob_get_contents) And the results are ... tada !!! test 1. diff test 2. equal While a diff between 2 files tell me that there are binary equivalent. Any idea how to fix this problem ? With : Script used to see the problem in action [1], with template [2] that produce general.exp (line 138) and general.out (line 144) Laurent [1] http://cvs.php.net/viewvc.cgi/pear/PEAR_Info/tests/PEAR_Info_TestCase_Output.php?revision=1.1&content-type=text%2Fplain&pathrev=1.1 [2] http://cvs.php.net/viewvc.cgi/pear/PEAR_Info/tests/templates/general.tpl?view=log

« previous php.pear.dev (#47271) next »