Leanpub Header

Skip to main content

The Grumpy Programmer's Guide To Testing PHP Applications

16 years of testing advice to help you learn to test your PHP code no matter what framework you use

Learn how a Grumpy Programmer approaches testing PHP applications, covering both the technical and core skills you need to learn in order to make testing just a thing you do instead of a thing you struggle with.

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
About

About

About the Book

I’ve been trying to help people test their PHP code for a very long time, probably before some of you reading this even got started in programming. PHPUnit didn’t exist, the most commonly-used version of PHP was 5.0, and social media wasn’t a thing. GMail had just started being used. My first search engine was Altavista. Yes, I learned to test uphill, both ways, in the snow.

I feel that testing, as a concept, is hard to explain to beginning programmers: “we are going to write code that is going to make sure your other code works as expected”. The assumption that underlies all this is that you already understand how to write computer programs in your chosen language! This makes it very difficult to teach to beginner or inexperienced programmers. When you combine this with how PHP does not force any particular structure on you, you have an environment where only the folks who are really motivated end up learning about testing.

The Grumpy Programmer's Guide To Testing PHP Applications is my way to try and provide some help for developers who are looking to become more test-centric and reap the benefits of automated testing and related tooling like static analysis and automation. I believe that by learning the skills (both technical and core) surrounding testing you will be able to write tests using almost any testing framework and almost any PHP application.

The book combines all the material from my previous books, adds new material, and revisits some old topics where my experiences have changed my thoughts. I break the vast topic of testing into smaller chunks, along with providing lots of examples and explanations of how I approach testing applications. Some of the things I cover are:

  • Test-Driven development
  • Strategies for Test-After practices
  • Test refactoring strategies
  • How PHPUnit itself works
  • Complementary tools and approaches like static analysis and mutation testing
  • Learning the core skills you need to get other people testing their code

The Grumpy Programmer's Guide To Testing PHP Applications is designed to be the book you refer to over and over again to not only learn how to test your PHP applications but to also remind yourself about techniques and tools that lead to successful outcomes. All I've ever wanted to do is get more people testing their code so we can concentrate on solving problems instead of constantly fixing bugs that we might've caught earlier.

Share this book

Price

Pick Your Price...

Minimum price

$24.00

$39.00

You pay

$39.00

Author earns

$31.20
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 2)

2
The author will earn $24.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

Chris Hartjes

Chris Hartjes has been helping teams try and produce fewer bugs in production since 1998 with a recent focus on tools and test automation in PHP and Python.

He lives in the snowy wilds of Lucan, Ontario, Canada,

Leanpub Podcast

Episode 68

An Interview with Chris Hartjes

Translations

Translations

Languages

Contents

Table of Contents

Introduction

  1. Changing How We Think About Tests
  2. It’s A Funnel, Not A Pyramid.
  3. Customer Tests and Developer Tests
  4. What Are Tests?
  5. Prerequisites
  6. Manual Tests
  7. Semi-Automated Tests Using Real Dependencies
  8. Semi-Automated Tests Using Test Doubles
  9. Automated Tests
  10. Final Thoughts
  11. How PHPUnit Works
  12. High-Level Overview
  13. How Do We Install PHPUnit?
  14. The PHPUnit Test Runner
  15. PHPUnit Test Cases
  16. Test Double
  17. What Is a Test Double?
  18. Dummies
  19. Test Stub
  20. Mock Objects and Test Spies
  21. Fakes
  22. Final Thoughts
  23. Test-Driven Development by Example
  24. Tooling
  25. Getting Started
  26. First Test
  27. Next Test
  28. Building Further Test Cases
  29. Refactoring The Tests
  30. Handling Non-Valid Input
  31. Final Thoughts
  32. Test-After Development by Example
  33. What’s the Difference?
  34. What Is the Expected Behavior?
  35. How Am I Going to Test This?
  36. Refactoring Helpers
  37. Testing APIs
  38. Response Validation
  39. API Schema Validation
  40. Data Providers
  41. Why You Should Use Data Providers
  42. Look at All Those Tests
  43. Creating Data Providers
  44. More Complex Examples
  45. Data Provider Tricks
  46. Final Thoughts
  47. Wrappers
  48. Wrappers From Up High
  49. Metatesting
  50. Mature Testing Tools Are Available
  51. Open Source Drives Acceptance
  52. Proof Exists to Back the Promises
  53. Testing Moves Bug Fixing to a Cheaper Part of the Cycle
  54. Well-Documented Build Systems Encourage Continuous Deployment
  55. There Are Awesome Complementary Tools
  56. Building a Testing Culture
  57. Primary Goal
  58. Tests as First Class Components
  59. Tests for Bugs
  60. Tests for New Features
  61. Tests for Refactoring
  62. Commitment to Peer Review
  63. Consistency in Development Environments
  64. Automation Is Your Friend
  65. Same Languages and Tools
  66. Same Practices
  67. Trust
  68. Bootstrapping
  69. Test Environment Bootstrapping
  70. Auto-Wiring Bootstrapping
  71. No Tests? No Problem!
  72. How Did We End Up Without Any Tests?
  73. Bug Fixes Need Proof
  74. New Features Require Proof
  75. Test Suites Are Not Bulletproof
  76. Nobody Is Running the Tests!
  77. Time Pressure
  78. Tests Are Too Slow
  79. Monolithic Bootstrapping
  80. Shared Testing Environments
  81. Testing Is Part of the Job
  82. Lost Opportunity Costs
  83. It’s About People
  84. Like Kids on a Playground
  85. Lack of Good Docs
  86. Convincing People About Time
  87. Cowboys Above Me

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub