phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

assertNotEquals not type-safe

Open gregbair opened this issue 15 years ago • 2 comments

class NullTest extends PHPUnit_Framework_TestCase
{
        public function testNullEqualsFalse()
        {
                $this->assertNotEquals(FALSE,NULL);
        }
}
greg@debian:~$ phpunit NullTest.php
PHPUnit 3.5.15 by Sebastian Bergmann.

F

Time: 0 seconds, Memory: 3.50Mb

There was 1 failure:

1) NullTest::testNullEqualsFalse
Failed asserting that <null> is not equal to <boolean:false>.

/home/greg/NullTest.php:7

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

This should not fail.

gregbair avatar Oct 17 '11 21:10 gregbair

@gregbair assertEquals does not use the strict comparison in PHPUnit. What you want to use in your case is assertNotSame

stof avatar Oct 24 '11 16:10 stof

Yeah thats by design as @stof said :)

edorian avatar Nov 10 '11 09:11 edorian