When I use method assertEquals() in class PHPUnit_Framework_Testcase and compare:
_false_ against _NULL_,
_empty string_ against _false_,
_empty string_ against _NULL_
All the tests pass sucessfully. But no value is equal to each other. So assertEquals compares with "==" operator instead of "===" or something like that. Think it's supposed to be as it is. But why?
We have assertSame()
for ===
comparisons.
Okay perfect. The names are a bit missleading. But it's my fault. Sorry for that.
But assertSame()
will only compare true
, if the objects are the same.
class Foo {}
$this->assertSame(new Foo(), new Foo());
Failed asserting that two variables reference the same object.
I need some code that can works like this:
$this->assertSame(new Foo(null), new Foo("")); // false
$this->assertSame(new Foo(null), new Foo(null)); // true
$this->assertSame(new Foo(""), new Foo("")); // true
Most helpful comment
We have
assertSame()
for===
comparisons.