PHPUnit Essentials


PHPUnit Essentials
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.95
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$67.94
save 6%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Learn how to install PHPUnit as well as how to write and execute tests
  • Understand the advanced concepts of testing using test doubles and the continuous integration process
  • A hands-on, step-by-step guide full of real-life examples to help you learn quickly and effectively

Book Details

Language : English
Paperback : 314 pages [ 235mm x 191mm ]
Release Date : May 2014
ISBN : 1783283432
ISBN 13 : 9781783283439
Author(s) : Zdenek Machek
Topics and Technologies : All Books, Application Development, Web Development, Open Source


Table of Contents

Preface
Chapter 1: Installing PHPUnit
Chapter 2: PHPUnit Support in IDEs
Chapter 3: Tests and What They're All About
Chapter 4: Testing Dependencies and Exceptions
Chapter 5: Running Tests from the Command Line
Chapter 6: Test Isolation and Interaction
Chapter 7: Organizing Tests
Chapter 8: Using Test Doubles
Chapter 9: Database Testing
Chapter 10: Testing APIs
Chapter 11: Testing Legacy Code
Chapter 12: Functional Tests in the Web Browser Using Selenium
Chapter 13: Continuous Integration
Chapter 14: PHPUnit Alternatives, Extensions, Relatives, and BDD
Index
  • Chapter 1: Installing PHPUnit
    • Requirements
      • Running PHP from the command line
    • Composer – the dependency manager for PHP
      • Installing Composer
      • Installation
        • Local installation
        • System-wide installation
    • Installing PEAR
      • PHPUnit installation
    • Other installation methods
      • Installing the Linux package
      • Manual installation
    • Testing the installation
      • Xdebug
        • Installing Xdebug
    • Summary
  • Chapter 3: Tests and What They're All About
    • Understanding unit testing
      • What is a unit test?
      • Assertions
      • The importance of unit testing
      • Testing all possible scenarios
      • What makes a good test?
      • When to write tests
    • Anatomy of a PHPUnit test
      • Defining test methods
      • Testing functions
      • Testing methods
    • The MVC application architecture and tests
      • Testing controllers
    • Summary
  • Chapter 5: Running Tests from the Command Line
    • Running tests
      • Processing test results
        • Test statuses
      • Command-line switches
        • Logging results
        • Code coverage
        • Including and excluding tests from the execution
        • When to stop the test execution
        • Configuration options
      • Code coverage analysis
    • Summary
  • Chapter 7: Organizing Tests
    • The PHPUnit XML configuration file
      • Test listeners
      • Configuring the code coverage
    • Where to store tests
      • Test suites
      • Groups
    • Using the bootstrap file
    • Summary
  • Chapter 8: Using Test Doubles
    • Creating test doubles
    • Test doubles in action
      • Using fake
      • Using stubs
      • Using mocks and expectations
      • Test proxies
    • Understanding Mockery
      • Installation methods
      • Comparing Mockery to PHPUnit
      • How to use Mockery
    • Summary
  • Chapter 9: Database Testing
    • Which database to use
    • Tests for a database
    • DBUnit
      • Installing DBUnit
      • Database test cases
      • Datasets
      • Using DBUnit
    • Doctrine 2 ORM and database testing
    • Summary
  • Chapter 10: Testing APIs
    • An example of integration testing
    • Testing the PayPal API
    • Testing the Facebook API
    • Testing the Twitter API
    • Testing the service-oriented architecture
    • Summary
  • Chapter 11: Testing Legacy Code
    • Testing spaghetti code
      • Black box testing
      • Using Reflection
    • Handling dependencies
      • The Patchwork library
      • The vfsStream library
      • The runkit PHP extension
    • Summary
  • Chapter 12: Functional Tests in the Web Browser Using Selenium
    • Installing Selenium
      • The Selenium IDE
      • The Selenium Server
        • Installing drivers
      • The PHPUnit Selenium extension
    • Testing in the browser
      • Recording Selenium tests
      • PHPUnit Selenium2TestCase
    • Writing Selenium tests
    • PHP-SeleniumClient
    • Organizing Selenium tests
    • Summary
  • Chapter 13: Continuous Integration
    • Using a Travis CI hosted service
      • Setting up Travis CI
      • Using Travis CI
    • Using the Jenkins CI server
      • Installation
      • Usage
        • Creating a job
        • Results
    • Using the Xinc PHP CI server
      • Installation
      • Usage
    • Summary

Zdenek Machek

Zdenek Machek is an experienced PHP developer, who has been working with PHP since the year 2000 and PHP3 days. He introduced software testing and PHPUnit to various companies, and used them on various small as well as large scale projects.

Zdenek wrote several articles and blog posts focused on Continuous Integration processes during PHP application development.

Currently, Zdenek leads technology standards and values across the organization, and also handles analysis, planning, and technical delivery of large scale, critical, and high performance systems for our most complex projects.

Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

PHPUnit Essentials +    Node.js Blueprints =
50% Off
the second eBook
Price for both: $41.55

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • How to install PHPUnit and confi gure IDEs for PHPUnit support
  • What are unit tests and why to test code
  • Write test doubles and learn how to replace dependencies
  • Explore how to test legacy code
  • Test code calling APIs and connecting to the database
  • Run functional tests in a web browser using Selenium tests
  • Use tests as part of the continuous integration process
  • Discover the alternatives to PHPUnit
  • Use PHPUnit tests in the Jenkins and Travis CI servers

In Detail

The ability to write unit tests and software testing have become skills that every PHP developer should master.

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.

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.

Approach

This book is a practical guide featuring a step-by-step approach that aims to help PHP developers who want to learn or improve their software testing skills. It also takes you through many real-life examples encountered by PHP developers to help you avoid common pitfalls.

Who this book is for

This book is a practical guide featuring a step-by-step approach that aims to help PHP developers who want to learn or improve their software testing skills. It also takes you through many real-life examples encountered by PHP developers to help you avoid common pitfalls.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software