sebastianbergmann/phpunit — Issue #412: assertEquals gives false result when fed an object with an empty __toString() in 3.6.3
Author: mroyiweb
Created: 2011-11-17 14:19:08+00:00
State: open

PHPUnit 3.6.3

It would seem that the new $this->assertEquals uses a factory to obtain a comparator, in my case it uses the Scalar one (PHPUnit/Framework/Comparator/Scalar.php) and at line 99 you can see it check if one of the 2 operands is a string, then cast both to string. This is a pretty big problem as when an object is cast to string, the __toString is called and if the object implements it and returns an empty string, the comparision passes.

Here's an example :

```PHP
assertEquals($expected, $actual);
}
}
```

PHPUnit 3.6.3 : Passes.
PHPUnit 3.5.15 : Doesn't passes.

I think that this test should not pass.

Thank you