talira

A PHP mocking framework that verifies calls after the fact, like Mockito.

open sourcePhake BSD 3-clause licencefree

Phake is a PHP framework for mock objects, test doubles and method stubs. Inspired by Java's Mockito, it uses a verification strategy: you run the code under test as normal and then verify which methods were called, rather than laying out expectations beforehand as PHPUnit's built-in mocks do.

Problems it solves

  • mock a class in my PHP tests and check afterwards which methods were called
  • stub a dependency's return value in a PHP unit test
  • a Mockito-style mocking library for PHP

Features

  • mock objects, test doubles and method stubs
  • verify calls after running the code (Mockito-style)
  • mocking static methods
  • parameter matchers and answers

Alternatives

The same job

These do what Phake does.

  1. Mockery Mock object framework for PHP unit tests
  2. Prophecy Opinionated, flexible object mocking framework for PHP

Compare Phake with the top 3