Shift with red gradient lettering
Loading navigation...

Double Converter

The Double Converter automates the process of converting your test suite from using the Mockery mocking library to use the Double library.

Double is a modern PHP test double library that puts developer experience first with zero learning curve, failures for humans, and one clean API.

After running the Double Converter, your Mockery mocks and expectations will be converted to their Test Double equivalents, removing the mockery/mockery dependency from your test suite.

Screenshot of a pull request with automated changes from the Double Converter

Requirements

  • A test suite using mockery/mockery
  • Running PHP 8.3 or higher

Automated Conversions

The Double Converter automates the following conversions:

  • Adds the jasonmccreary/test-double dependency.
  • Converts double creation with Mockery::mock() and Mockery::spy().
  • Expands Mockery shorthands into explicit calls.
  • Converts expectations chains.
  • Converts argument matchers, such as Mockery::any().
  • Converts verifications.
  • Converts invoke assertions for called and uncalled doubles.

Manual Conversions

The Double Converter targets common Mockery expectation patterns, but some chains are too complex to safely rewrite automatically, including "bare mocks", complex shorthands, and some argument matcher. Shift will leave a detailed comment for anything it can not convert so you may complete your conversion from Mockery to Double.