转自http://blog.csdn.net/summerfang/archive/2006/05/20/746219.aspx
很长时间里,我对“你什么时候会为PHPUnit写一个文档”这个问题的回答是:“你不需要PHPUnit文档,去读读JUnit文档或买一本Junit的书,试一试用PHP和PHPUnit来重写Java和Junit的例子”。当我和O’Reilly德国办公室的Barbara Weiss和Alexandra Follenius这样说的时候,他们鼓励我想想是不是可以写一本书来作为PHPUnit的文档。
1.1 基本要求
本书的主题是PHPUnit,这是一个支持用PHP进行测试驱动开发的开放源代码框架。本书覆盖了PHPUnit 2.3,需要PHP5.1支持。当然,大部分例子在PHPUnit 2.02.2和PHP5.0也都可以运行。本书的后半部分,“在PHP4中使用PHPUnit”一章中,覆盖了老式的,不再进一步积极发展的在PHP4中运行的PHPUnit。
本书的读者需要对使用PHP5进行面向对象编程要很好的理解。建议德文读者读读我写的Professionelle Softwareentwicklung mit PHP 5一书,这是对使用PHP5进行面向对象编程的介绍。英文读者可以参考Andi Gutmans, Stig Bakken和Derick Rethans合著的PHP 5 Power Programming。
1.2 本书是自由发布的
本书可以在Creative Commons license版权公约下自由获得。访问http://www.phpunit.de/pocket_guide/你可以总是发现本书的最新版本。你根据自己的需要修改和重新发布。当然,相比你发布你自己的版本,我更推荐你发送反馈和更新给[email protected]
1.3 本书的约定
下面是本书的一些书写约定:
斜体
表示新名词,URL,邮件地址,文件名,文件扩展名,路径名,目录和Unix应用程序
固定宽度字体
表示命令,选项,开关语句,变量,函数,类,名字空间,方法,模块,参数,值,对象,文件内容或命令输出。
固定宽度加重字体
表示需要读者逐字逐句输入的命令或文本内容。
固定宽度斜体
表示需要用读者自己的值替代的文本。
辅助信息
这是一个辅助信息,是建议或者普通注释。它包含了关于相关主题有用的辅助内容。
警告
这是一个提醒注意的警告或注释
1.4 如何联系我们
我们已经尽力测试和验证过本书的内容,但是你还是可能发现特性改变了,甚至有错误!
作为本书的读者,你可以通过发送反馈给我来帮助我们改进未来的版本。请告诉我们任何书中的错误,不精确,臭虫,误导、混淆语句或输入错误。
也请你让我们知道如果能让本书更有用。我们会慎重对待你的来信,并尽力在未来版本加以改进。你可以发信到如下地址:
O'Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol , CA 95472
(800) 998-9938 (in the U.S. or Canada )
(707) 829-0515 (international/local)
(707) 829-0104 (fax)
如果想问技术问题,或对本书发表评论,可以发送到[email protected]。
PHPUnit口袋书指南的网站列出了例子,勘误表和未来的版本计划。你可以在如下网址找到它们:
http://www.oreilly.com/catalog/phpunitpg
想要更多本书或其他书籍更多信息,请访问O’Reilly的网站:
http://www.oreilly.com
1.5 鸣谢
我要感谢Kent Beck和Erich Gamma发明了Junit给了我发明PHPUnit的灵感,我更要谢谢Kent Beck写了Junit口袋书一书,这使我有了写本书的冲动。同时我要感Allison Randal, Alexandra Follenius和Barbara Weiss,是他们在O’Reilly负责本书。
我要感谢Andi Gutmans, Zeev Suraski和Marcus Börger,是他们开发了PHP5的核心Zend Engine 2。我还有谢谢Derick Rethans,他开发了PHP扩展功能Xdebug,使得PHPUnit的代码覆盖率功能成为可能。最后,我还有谢谢Michiel Rook,他写了Phing的PHPUnit任务。
--------------------------------------------------------------------------------------------------------------
原文:
Chapter 1. Introduction
For a very long time, my answer to the question, "When will you write documentation for PHPUnit?" has been, "You do not need documentation for PHPUnit. Just read the documentation for JUnit or buy a book on JUnit and adapt the code examples from Java™ and JUnit to PHP and PHPUnit." When I mentioned this to Barbara Weiss and Alexandra Follenius from the O'Reilly Germany office, they encouraged me to think it over and write a book that would serve as the documentation for PHPUnit.
1.1. Requirements
The topic of this book is PHPUnit, an open source framework for test-driven development with the PHP programming language. This book covers Version 2.3 of PHPUnit, which requires PHP 5.1. However, most of the examples should work with PHPUnit Versions 2.02.2, as well as PHP 5.0. The "PHPUnit for PHP 4" section, later in this book, covers the older, no longer actively developed version of PHPUnit for PHP 4.
The reader should have a good understanding of object-oriented programming with PHP 5. To German readers, I recommend my book Professionelle Softwareentwicklung mit PHP 5 as an introduction to object-oriented programming with PHP 5. A good English book on the subject is PHP 5 Power Programming by Andi Gutmans, Stig Bakken, and Derick Rethans (Prentice Hall PTR).
1.2. This Book Is Free
This book is available under the Creative Commons license. You will always find the latest version of this book at its web site: http://www.phpunit.de/pocket_guide/. You may distribute and make changes to this book however you wish. Of course, rather than distribute your own private version of the book, I would prefer you send feedback and patches to [email protected].
1.3. Conventions Used in This Book
The following is a list of the typographical conventions used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, file extensions, pathnames, directories, and Unix utilities.
Constant width
Indicates commands, options, switches, variables, functions, classes, namespaces, methods, modules, parameters, values, objects, the contents of files, or the output from commands.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values.
You should pay special attention to notes set apart from the text with the following styles:
TIP
This is a tip, suggestion, or general note. It contains useful supplementary information about the topic at hand.
WARNING
This is a warning or note of caution.
1.4. How to Contact Us
We have tested and verified the information in this book to the best of our ability, but you may find that features have changed (or even that we have made mistakes!).
As a reader of this book, you can help us to improve future editions by sending us your feedback. Please let us know about any errors, inaccuracies, bugs, misleading or confusing statements, and typos that you find anywhere in this book.
Please also let us know what we can do to make this book more useful to you. We take your comments seriously and will try to incorporate reasonable suggestions into future editions. You can write to us at:
O'Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol , CA 95472
(800) 998-9938 (in the U.S. or Canada )
(707) 829-0515 (international/local)
(707) 829-0104 (fax)
To ask technical questions or to comment on the book, send email to:
The web site for PHPUnit Pocket Guide lists examples, errata, and plans for future editions. You can find this page at:
http://www.oreilly.com/catalog/phpunitpg
For more information about this book and others, see the O'Reilly web site:
http://www.oreilly.com
1.5. Acknowledgments
I would like to thank Kent Beck and Erich Gamma for JUnit and for the inspiration to write PHPUnit. I would also like to thank Kent Beck for his JUnit Pocket Guide, which sparked the idea for this book. I would like to thank Allison Randal, Alexandra Follenius, and Barbara Weiss for sponsoring this book at O'Reilly.
I would like to thank Andi Gutmans, Zeev Suraski, and Marcus Börger for their work on the Zend Engine 2, the core of PHP 5. I would like to thank Derick Rethans for Xdebug, the PHP extension that makes PHPUnit's code-coverage functionality possible. Finally, I would like to thank Michiel Rook, who wrote the PHPUnit tasks for Phing.