2

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.

1
  • 5
    Post your code... And you will get answers... Commented Jan 16, 2013 at 12:56

1 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.