Instant Hands-on Testing with PHPUnit How-to

A practical guide to getting started with PHPUnit to improve code quality

Instant Hands-on Testing with PHPUnit How-to

Michael Lively

A practical guide to getting started with PHPUnit to improve code quality
Mapt Subscription
FREE
$29.99/m after trial
eBook
$10.50
RRP $14.99
Save 29%
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$10.50
$29.99p/m after trial
RRP $14.99
Subscription
eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781782169581
Paperback82 pages

Book Description

No developer wants to accept the inherent difficulty of writing software as an excuse for not finding the bugs in our code before anyone else does. PHPUnit is a framework that was created to allow developers to solve that very problem. It provides a feature-rich environment with most of the tools necessary to provide adequate tests for any project.

"Instant Hands-on Testing with PHPUnit How-to" provides a thorough overview of the functionality provided by the PHPUnit framework. It shows how the plethora of features in the framework can be used to write tests for real world projects to ensure they function and will continue to function in the ways that you expect.

This book will show how you can set up the scaffolding necessary to run unit tests in your project with PHPUnit. It will walk you through the process of how to write a basic test and how to maintain your project’s test suite. You will learn how to use some of the more advanced features of PHPUnit and then see how you can use mock objects to isolate the code you are testing. We will then discover how to create tests that verify your interaction with databases and even see how you can use PHPUnit to understand which code you are actually testing.

At the end of the book you will have all of the basic understanding necessary to begin adding tests to your project. This book provides a great foundation for becoming a expert at writing unit tests.

Table of Contents

Chapter 1: Instant Hands-on Testing with PHPUnit How-to
Installing PHPUnit (Simple)
Writing your first test (Simple)
Running tests (Simple)
Configuring PHPUnit (Simple)
Adding PHPUnit to your project (Simple)
Generating tests from code (Advanced)
Using test fixtures (Simple)
Using data providers (Intermediate)
Using test dependencies (Advanced)
Using mock objects (Simple)
Testing abstract classes (Intermediate)
Testing traits (Intermediate)
Testing exceptions and errors (Intermediate)
Testing output (Intermediate)
Testing protected and private methods (Intermediate)
Testing database interaction (Advanced)
Viewing code coverage (Advanced)

What You Will Learn

  • Bootstrap PHPUnit into your project in a standard way
  • Understand the anatomy of a PHPUnit test
  • Create data providers to quickly create tests against multiple datasets
  • Use PHPUnit’s skeleton generator to generate code from tests or tests from code
  • Declare test dependencies to help isolate test failures
  • Test abstract classes, traits, and protected methods
  • Test database interactions in your unit tests

Authors

Table of Contents

Chapter 1: Instant Hands-on Testing with PHPUnit How-to
Installing PHPUnit (Simple)
Writing your first test (Simple)
Running tests (Simple)
Configuring PHPUnit (Simple)
Adding PHPUnit to your project (Simple)
Generating tests from code (Advanced)
Using test fixtures (Simple)
Using data providers (Intermediate)
Using test dependencies (Advanced)
Using mock objects (Simple)
Testing abstract classes (Intermediate)
Testing traits (Intermediate)
Testing exceptions and errors (Intermediate)
Testing output (Intermediate)
Testing protected and private methods (Intermediate)
Testing database interaction (Advanced)
Viewing code coverage (Advanced)

Book Details

ISBN 139781782169581
Paperback82 pages
Read More

Read More Reviews

Recommended for You

Responsive Web Design with HTML5 and CSS3 Book Cover
Responsive Web Design with HTML5 and CSS3
$ 23.99
$ 4.80
Mastering Web Application Development with AngularJS Book Cover
Mastering Web Application Development with AngularJS
$ 26.99
$ 5.40
Expert PHP 5 Tools Book Cover
Expert PHP 5 Tools
$ 29.99
$ 21.00
jQuery UI 1.7: The User Interface Library for jQuery  Book Cover
jQuery UI 1.7: The User Interface Library for jQuery
$ 26.99
$ 18.90
RESTful PHP Web Services Book Cover
RESTful PHP Web Services
$ 23.99
$ 16.80
Responsive Web Design by Example : Beginner's Guide Book Cover
Responsive Web Design by Example : Beginner's Guide
$ 26.99
$ 18.90