Instant Hands-on Testing with PHPUnit How-to
()
About this ebook
Related to Instant Hands-on Testing with PHPUnit How-to
Related ebooks
Instant Magento Performance Optimization How-to Rating: 0 out of 5 stars0 ratingsMeteor Design Patterns Rating: 0 out of 5 stars0 ratingsPersistence in PHP with Doctrine ORM Rating: 0 out of 5 stars0 ratingsRedmine Plugin Extension and Development Rating: 0 out of 5 stars0 ratingsAdministrating Solr Rating: 0 out of 5 stars0 ratingsApache Solr PHP Integration Rating: 0 out of 5 stars0 ratingsJasmine JavaScript Testing - Second Edition Rating: 0 out of 5 stars0 ratingsNW.js Essentials Rating: 0 out of 5 stars0 ratingsGetting Started with hapi.js Rating: 5 out of 5 stars5/5Learning Bootstrap Rating: 1 out of 5 stars1/5Learning Behavior-driven Development with JavaScript Rating: 5 out of 5 stars5/5Instant Jsoup How-to Rating: 0 out of 5 stars0 ratingsModular Programming with PHP 7 Rating: 0 out of 5 stars0 ratingsPractical Django 2 and Channels 2: Building Projects and Applications with Real-Time Capabilities Rating: 0 out of 5 stars0 ratingsBuilding a Web Application with PHP and MariaDB: A Reference Guide Rating: 0 out of 5 stars0 ratingsLearning Yii Testing Rating: 1 out of 5 stars1/5jQuery UI 1.7: The User Interface Library for jQuery Rating: 0 out of 5 stars0 ratingsSoftware architecture A Complete Guide - 2019 Edition Rating: 0 out of 5 stars0 ratingsFlex 3 with Java Rating: 0 out of 5 stars0 ratingsInstant Magento Shipping How-To Rating: 0 out of 5 stars0 ratingsPHP for Beginners Rating: 0 out of 5 stars0 ratingsMastering Ext JS - Second Edition Rating: 0 out of 5 stars0 ratingsResponsive Web Design A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsFlash with Drupal Rating: 0 out of 5 stars0 ratingsSymfony2 Essentials Rating: 0 out of 5 stars0 ratingsXamarin Mobile Application Development for Android - Second Edition Rating: 0 out of 5 stars0 ratingsResponsive Media in HTML5 Rating: 0 out of 5 stars0 ratingsMulti-Tier Application Programming with PHP: Practical Guide for Architects and Programmers Rating: 0 out of 5 stars0 ratingsGetting Started with Magento Extension Development Rating: 0 out of 5 stars0 ratingsReal-World Solutions for Developing High-Quality PHP Frameworks and Applications Rating: 3 out of 5 stars3/5
Computers For You
SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Elon Musk Rating: 4 out of 5 stars4/5The Invisible Rainbow: A History of Electricity and Life Rating: 4 out of 5 stars4/5Slenderman: Online Obsession, Mental Illness, and the Violent Crime of Two Midwestern Girls Rating: 4 out of 5 stars4/5Standard Deviations: Flawed Assumptions, Tortured Data, and Other Ways to Lie with Statistics Rating: 4 out of 5 stars4/5Mastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 5 out of 5 stars5/5Everybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5101 Awesome Builds: Minecraft® Secrets from the World's Greatest Crafters Rating: 4 out of 5 stars4/5CompTIA IT Fundamentals (ITF+) Study Guide: Exam FC0-U61 Rating: 0 out of 5 stars0 ratingsAlan Turing: The Enigma: The Book That Inspired the Film The Imitation Game - Updated Edition Rating: 4 out of 5 stars4/5Procreate for Beginners: Introduction to Procreate for Drawing and Illustrating on the iPad Rating: 0 out of 5 stars0 ratingsThe Hacker Crackdown: Law and Disorder on the Electronic Frontier Rating: 4 out of 5 stars4/5Dark Aeon: Transhumanism and the War Against Humanity Rating: 5 out of 5 stars5/5The ChatGPT Millionaire Handbook: Make Money Online With the Power of AI Technology Rating: 0 out of 5 stars0 ratingsCreating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5Childhood Unplugged: Practical Advice to Get Kids Off Screens and Find Balance Rating: 0 out of 5 stars0 ratingsAP Computer Science Principles Premium, 2024: 6 Practice Tests + Comprehensive Review + Online Practice Rating: 0 out of 5 stars0 ratingsCompTIA Security+ Practice Questions Rating: 2 out of 5 stars2/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Going Text: Mastering the Command Line Rating: 4 out of 5 stars4/5The Professional Voiceover Handbook: Voiceover training, #1 Rating: 5 out of 5 stars5/5People Skills for Analytical Thinkers Rating: 5 out of 5 stars5/5Remote/WebCam Notarization : Basic Understanding Rating: 3 out of 5 stars3/5How to Create Cpn Numbers the Right way: A Step by Step Guide to Creating cpn Numbers Legally Rating: 4 out of 5 stars4/5
Reviews for Instant Hands-on Testing with PHPUnit How-to
0 ratings0 reviews
Book preview
Instant Hands-on Testing with PHPUnit How-to - Michael Lively
Table of Contents
Instant Hands-on Testing with PHPUnit How-to
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Instant Hands-on Testing with PHPUnit How-to
Installing PHPUnit (Simple)
How to do it...
How it works...
There's more...
Installing PHPUnit using Composer
Installing PHPUnit on older versions of PHP
Writing your first test (Simple)
Getting ready...
How to do it...
How it works...
There's more...
Class names
Running tests (Simple)
How to do it...
How it works...
There's more...
Command line options
--colors
--stop-on-error and --stop-on-failure
--debug
--strict
Configuring PHPUnit (Simple)
How to do it...
How it works...
There's more...
Additional configurations
Using phpunit.xml.dist
Adding PHPUnit to your project (Simple)
Getting ready...
How to do it…
How it works…
There's more...
Generating tests from code (Advanced)
Getting ready
How to do it...
How it works...
There's more...
Using @assert to generate additional code
Using the Skeleton Generator for test-driven development
Using test fixtures (Simple)
How to do it...
How it works...
There's more...
Using data providers (Intermediate)
How to do it...
How it works...
Identifying test failures
Using test dependencies (Advanced)
How to do it...
How it works...
Multiple test dependencies
Multiple dependent tests
Using mock objects (Simple)
How to do it...
How it works...
There's more...
Thoughts on partial mocks
Ignoring parameters on method expectations
Stubbing exceptions
Stubbing multiple return values
Stubbing with callbacks
Using mock builders
Using alternative mock frameworks
Phake
Mockery
Testing abstract classes (Intermediate)
How to do it...
How it works...
Abstract classes in Phake
Testing traits (Intermediate)
How to do it...
How it works...
Testing exceptions and errors (Intermediate)
How to do it...
How it works...
There's more...
Testing output (Intermediate)
How to do it...
How it works...
There's more...
Testing protected and private methods (Intermediate)
How to do it...
How it works...
Private and protected methods
Testing database interaction (Advanced)
Getting ready
How to do it...
How it works...
There's more...
Alternate data sets
Flat XML data set
MySQL XML data set
YAML data set
Validating your data with queries
Viewing code coverage (Advanced)
Getting ready
How to do it...
How it works...
Instant Hands-on Testing with PHPUnit How-to
Instant Hands-on Testing with PHPUnit How-to
Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: May 2013
Production Reference: 1170513
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78216-958-1
www.packtpub.com
Credits
Author
Michael Lively
Reviewers
Brian Feaver
Adam Englander
Acquisition Editor
Mary Jasmine Nadar
Commissioning Editor
Yogesh Dalvi
Technical Editor
Worrell Lewis
Project Coordinator
Michelle Quadros
Proofreader
Lydia May Morris
Production Coordinator
Melwyn D'sa
Cover Work
Melwyn D'sa
Cover Image
Aditi Gajjar
About the Author
Michael Lively has worked in a variety of roles in the software development industry for 12 years, from developer to architect and now a software development director. He has worked on a variety of different projects and a variety of different technologies over that time, from small home-grown sites serving a handful of regular users to large enterprise platforms serving millions of consumers. In addition to his professional work, he has been an active member of the PHP open source community. Some of his contributions include the database extension for PHPUnit and more recently an alternative mocking framework for PHP called Phake.
I would like to thank everyone who, over the years, has given me opportunities to work in and with the technology industry. From my schooling to the present day I have had the fortunate blessing of meeting some of the most gifted and knowledgeable folks in the IT industry. Specifically, I would like to thank Sebastian Bergmann who introduced me to unit testing and provided me great opportunities to contribute back to the community. I would also like to thank Brian Feaver and Adam Englander. Both are fantastic co-workers and gave me lots of great feedback when I discussed topics for this book with them.
Last but certainly not least this journey called life would not be nearly as complete without my girls. I would like to thank my wonderful wife Sharon and my fantastic girls Trinity, Hannah, and Gracelyn. Their patience and willingness to chase my goals with me has made all the difference in the world.
About the Reviewers
Brian Feaver is the Lead Software Architect at Selling Source LLC. He's been a software developer for over 10 years, contributes to multiple open source projects, and participates in developer-user communities. He is a strong advocate of developer testing and automated testing in general.
Adam Englander is the CTO of Coupla where he leads their development and cloud platform initiatives. He is an accomplished software