testing

  • PHPUnit 6 renamed the classes into a namespace

    Version 6 moved everything under PHPUnitFramework and left aliases for the old names, which are deprecated. Every test file extending PHPUnit_Framework_TestCase needs a line changing. The rename is…

  • Designing an API two mobile clients can live with

    Two apps, two release cycles, and neither can be forced to update. What is additive, what is not, and the decisions that have to be made before the…

  • Data providers run before setUp, every time

    A provider that builds its cases from something created in setUp() fails with a null, because every provider in the class runs before any test does — including…

  • Schema changes that do not need a maintenance window

    An ALTER on a 40 million row table held a metadata lock behind every query. Expand, migrate, contract turns one blocking release into three safe ones.

  • Laravel 5.5 and the packages that install themselves

    The first release where installing a package is one command. Auto-discovery removes two config edits per package, and hides the fact that they happened.

  • Analysing the tests as well as the source

    Test code is usually excluded from static analysis on the grounds that it is not production code, which is where a good proportion of the useful findings are…

  • Assert against the database, not against the response

    A feature test asserting a 302 and a flash message proves the controller ran. It does not prove the order was created, and it passes just as happily…

  • Test doubles for an interface you do not own

    Mocking a third-party class binds the test to that class’s current signature, so an upgrade changing a method leaves the test passing against a shape that no longer…

  • A contract test for the API you depend on

    Mocking an upstream service makes the suite fast and guarantees nothing about the upstream still behaving that way. A contract test is a small suite that runs against…

  • WooCommerce 3.0 turned products into objects

    Every plugin reading _price from post meta is now reading a private field. The mechanical half, the half that is not, and the compatibility layer for code you…