Assertions and Test Methods
Use assertEquals, assertSame, assertNull, and other assertions.
What are Assertions?
Assertions verify that the actual output of code matches the expected value. PHPUnit provides a rich library of assertion methods.
assertEquals vs assertSame
assertEquals uses loose comparison (==). assertSame uses strict comparison (===) — checks type AND value.
<?php
$this->assertEquals(0, false); // passes (0 == false)
$this->assertSame(0, false); // FAILS (0 !== false)All lessons in this course
- PHPUnit Setup and First Test
- Assertions and Test Methods
- Data Providers for Parameterized Tests
- Mocking Dependencies with PHPUnit