I am running PHP 5.3.6 and the latest version of PHPUnit from Github. When I copy example 17.1 from the docs, it suffers a fatal error when the assertTitle fails. I get this error message:
Fatal error: Call to a member function toString() on a non-object in <path>/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumTestCase.php on line 1041
When I change the assertion to pass, PHPUnit runs just fine.
I dug up the line and this is the snippet :
protected function onNotSuccessfulTest(Exception $e)
{
if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
$buffer = 'Current URL: ' . $this->drivers[0]->getLocation() .
"\n";
$message = $e->getComparisonFailure()->toString();
$e->getComparisonFailure() returns NULL, not an object. What am I doing incorrectly?
UPDATE:
I found the reason for the failure, although a fix isn't on my horizon yet.
On line 92 of PHPUnit/Framework/Constraint.php, it calls using
$this->fail($other,$description)
which is defined as:
protected function fail($other, $description, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL)
Since no PHPUnit_Framework_ComparisonFailure is passed, NULL is passed on line 141 of PHPUnit/Framework/Constraint.php
throw new PHPUnit_Framework_ExpectationFailedException( $failureDescription, $comparisonFailure );
which is fetched by getComparisonFailure() which is supposed to return an object, as described above.
Any more ideas?