public function testAddition() { // initialize variables $a = 4; $b = 5; // perform addition $result = $a + $b; // test if result is equal to 9 $this->assertEquals(9, $result); }
class DatabaseTest extends \PHPUnit_Framework_TestCase { protected $db; public function setUp() { $this->db = new PDO('sqlite::memory:'); $this->db->exec('CREATE TABLE test (id INT, name VARCHAR(255))'); } public function tearDown() { $this->db->exec('DROP TABLE test'); } public function testInsertRow() { $this->db->exec("INSERT INTO test VALUES (1, 'foo')"); $result = $this->db->query('SELECT * FROM test')->fetchAll(); $this->assertCount(1, $result); } }From these examples, it is clear that PHPUnit_Framework_TestCase is a part of the PHPUnit library.