Book Image

PHPUnit Essentials

By : Zdenek Machek
Book Image

PHPUnit Essentials

By: Zdenek Machek

Overview of this book

<p>The ability to write unit tests and software testing have become skills that every PHP developer should master.<br /><br />This book is a practical guide to PHPUnit and unit testing, covering all aspects of writing PHPUnit tests and using them. The book shows why testable code is better code and how to write good tests with the help of simple and easy-to-understand examples.<br /><br />With this book, you will learn how to write, organize, and execute effective tests. Step-by-step techniques of how to write testable code, how to refactor the code, and how to run your tests are shown. You will also learn about advanced testing techniques, including how to test databases, APIs, and legacy code. PHPUnit Essentials is a guide for PHP developers who want to learn or improve their software testing skills. It is a book for developers who begin with testing but is also a good source of information for developers who are already familiar with PHPUnit.</p>
Table of Contents (21 chapters)
PHPUnit Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
5
Running Tests from the Command Line
Index

Summary


There are several ways to install PHPUnit. This chapter showed all the available options. The Composer and PEAR installation methods are recommended as they can handle all the required dependencies and allow to keep PHPUnit and the required libraries up to date. PHPUnit installation is not difficult if the right path is followed. Xdebug extension is optional, but it is strongly recommended that you install it as we will need extra features such as remote debugging and code coverage later.

When writing and running PHPUnit tests, it's really important to have a good IDE (Integrated Development Environment). All modern IDEs have good PHPUnit support. The next chapter will show the four most popular IDEs in PHP world. We will also see how to configure them, how to execute tests, and how to debug tests. Good support for PHPUnit and PHP in general is something that makes a developer's life much easier, and he/she is able to produce good code much faster than using an ordinary text editor.

To have PHPUnit installed is the first good step. In the next chapter, before jumping to writing tests, it's good to have a look at how to run and debug PHPUnit tests in IDE such as Zend Studio and NetBeans.