Smart web developers will tell you that the sooner you detect your code mistakes, the quicker you can fix them, and the less the project will cost in the long run. Well, the most efficient way to detect your mistakes in PHP is with PHPUnit, an open source framework that automates unit testing by running a battery of tests as you go. The benefits of PHPUnit are significant:a reduction in the effort required to frequently test code fewer overall defects added confidence in your code improved relations with your open source teammates The only problem with this popular testing tool was its lack of documentation-until now, that is. For this, O'Reilly went right to the source, as Sebastian Bergmann, the author of PHPUnit Pocket Guide, also happens to be PHPUnit's creator. This little book brings together hard-to-remember information, syntax, and rules for working with PHPUnit. It also delivers the insight and sage advice that can only come from the technology's creator. Coverage of testing under agile methodologies and Extreme Programming (XP) is also included. The latest in O'Reilly's series of handy Pocket Guides, this quick-reference book puts all the answers are right at your fingertips. It's an invaluable companion for anyone interested in testing the PHP code they write for web applications.
Author(s): Sebastian Bergmann
Series: Pocket Guides
Publisher: O'Reilly Media
Year: 2005
Language: English
Pages: 88
Contents......Page 6
Requirements......Page 10
Conventions Used in This Book......Page 11
How to Contact Us......Page 12
Automating Tests......Page 13
PHPUnit’s Goals......Page 16
Installing PHPUnit......Page 20
The Command-Line Test Runner......Page 21
Fixtures......Page 25
More setUp() than tearDown()......Page 27
Suite-Level Setup......Page 28
Testing Exceptions and Performance Regressions......Page 29
Exceptions......Page 30
Performance Regressions......Page 32
Incomplete Tests......Page 33
Test-First Programming......Page 34
BankAccount Example......Page 36
Code-Coverage Analysis......Page 41
Stubs......Page 43
Self-Shunting......Page 45
Agile Documentation......Page 46
Cross-Team Tests......Page 47
Debugging Tests......Page 48
PHPUnit and Phing......Page 49
Formatting Feedback......Page 51
PHPUnit’s Implementation......Page 57
Overview......Page 59
PHPUnit2_Framework_Assert......Page 60
PHPUnit2_Framework_TestCase......Page 66
PHPUnit2_Framework_TestSuite......Page 67
PHPUnit2_Framework_TestResult......Page 71
Package Structure......Page 74
Subclass PHPUnit2_Extensions_TestDecorator......Page 75
Implement PHPUnit2_Framework_Test......Page 77
Implement PHPUnit2_Framework_TestListener......Page 78
PHPUnit for PHP 4......Page 81
Bibliography......Page 84
Index......Page 86