Deep123
Deep123

Reputation: 391

PHPUnit assertTrue Issue

I am using PHPUnit to test my code But when i use assertTrue phpunit behaves expectly. Is this normal beahviour of phpunit or not. I got the following error.

Failed asserting that 1 is true.

Upvotes: 2

Views: 1912

Answers (1)

Magus
Magus

Reputation: 15124

1 is not a "real" true value. You can try this :

true == 1 // return true
true === 1 // return false
false == null // return true
false === null // return false

PHPUnit use === in assertTrue. So if you do assertTrue(1);, PHPUnit just stop because the assertion is false.

Upvotes: 8

Related Questions