PHPUnit袖珍指南-第一章 簡介

第一章 簡介

很長時間裏,我對“你什麼時候會爲PHPUnit寫一個文檔”這個問題的回答是:“你不需要PHPUnit文檔,去讀讀JUnit文檔或買一本Junit的書,試一試用PHPPHPUnit來重寫JavaJunit的例子”。當我和O’Reilly德國辦公室的Barbara WeissAlexandra Follenius這樣說的時候,他們鼓勵我想想是不是可以寫一本書來作爲PHPUnit的文檔。

1.1 基本要求

本書的主題是PHPUnit,這是一個支持用PHP進行測試驅動開發的開放源代碼框架。本書覆蓋了PHPUnit 2.3,需要PHP5.1支持。當然,大部分例子在PHPUnit 2.02.2PHP5.0也都可以運行。本書的後半部分,“在PHP4中使用PHPUnit”一章中,覆蓋了老式的,不再進一步積極發展的在PHP4中運行的PHPUnit

本書的讀者需要對使用PHP5進行面向對象編程要很好的理解。建議德文讀者讀讀我寫的Professionelle Softwareentwicklung mit PHP 5一書,這是對使用PHP5進行面向對象編程的介紹。英文讀者可以參考Andi Gutmans, Stig BakkenDerick 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, CA95472

(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 BeckErich Gamma發明了Junit給了我發明PHPUnit的靈感,我更要謝謝Kent Beck寫了Junit口袋書一書,這使我有了寫本書的衝動。同時我要感Allison Randal, Alexandra FolleniusBarbara Weiss,是他們在O’Reilly負責本書。

我要感謝Andi Gutmans, Zeev SuraskiMarcus Börger,是他們開發了PHP5的核心Zend Engine 2。我還有謝謝Derick Rethans,他開發了PHP擴展功能Xdebug,使得PHPUnit的代碼覆蓋率功能成爲可能。最後,我還有謝謝Michiel Rook,他寫了PhingPHPUnit任務。

 

--------------------------------------------------------------------------------------------------------------

原文:

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, CA95472

(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:

 

[email protected]

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.

 

發佈了13 篇原創文章 · 獲贊 0 · 訪問量 19萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章