Chapter 15. PHPUnit API
For most uses, PHPUnit has a simple API: subclass
PHPUnit2_Framework_TestCase
for your test cases and call assertTrue( )
or assertEquals( )
. However, for those of you who would like to look deeper into PHPUnit, here are all of its published methods and classes.
Overview
Most of the time, you will encounter five classes or interfaces when you are using PHPUnit:
- PHPUnit2_Framework_Assert
A collection of static methods for checking actual values against expected values
- PHPUnit2_Framework_Test
The interface of all objects that act like tests
- PHPUnit2_Framework_TestCase
A single test
- PHPUnit2_Framework_TestSuite
A collection of tests
- PHPUnit2_Framework_TestResult
A summary of the results of running one or more tests
Figure 7 shows the relationship of the five basic classes and interfaces in PHPUnit:
PHPUnit2_Framework_Assert, PHPUnit2_ Framework_Test, PHPUnit2_Framework_TestCase, PHPUnit2_ Framework_TestSuite
, and PHPUnit2_Framework_TestResult
.
Figure 1-7. The five basic classes and interfaces in PHPUnit
Get PHPUnit Pocket Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.