2017 © Pedro Peláez
 

library php-mock-prophecy

Mock built-in PHP functions (e.g. time()) with Prophecy. This package relies on PHP's namespace fallback policy. No further extension is needed.

image

php-mock/php-mock-prophecy

Mock built-in PHP functions (e.g. time()) with Prophecy. This package relies on PHP's namespace fallback policy. No further extension is needed.

  • Saturday, December 2, 2017
  • by malkusch
  • Repository
  • 2 Watchers
  • 12 Stars
  • 90,454 Installations
  • PHP
  • 12 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 3 Versions
  • 6 % Grown

The README.md

Mock PHP built-in functions with Prophecy

This package integrates the function mock library PHP-Mock with Prophecy., (*1)

Installation

Use Composer:, (*2)

composer require --dev php-mock/php-mock-prophecy

Usage

Build a new PHPProphet and create function prophecies for a given namespace with PHPProphet::prophesize():, (*3)

namespace foo;

use phpmock\prophecy\PHPProphet;

$prophet = new PHPProphet();

$prophecy = $prophet->prophesize(__NAMESPACE__);
$prophecy->time()->willReturn(123);
$prophecy->reveal();

assert(123 == time());
$prophet->checkPredictions();

Restrictions

This library comes with the same restrictions as the underlying php-mock:, (*4)

  • Only unqualified function calls in a namespace context can be prophesized. E.g. a call for time() in the namespace foo is prophesizable, a call for \time() is not., (*5)

  • The mock has to be defined before the first call to the unqualified function in the tested class. This is documented in Bug #68541. In most cases you can ignore this restriction. But if you happen to run into this issue you can call PHPProphet::define() before that first call. This would define a side effectless namespaced function., (*6)

  • Additionally it shares restrictions from Prophecy as well: Prophecy doesn't support pass-by-reference. If you need pass-by-reference in prophecies, consider using another framework (e.g. php-mock-phpunit)., (*7)

License and authors

This project is free and under the WTFPL. Responsable for this project is Markus Malkusch markus@malkusch.de., (*8)

Donations

If you like this project and feel generous donate a few Bitcoins here: 1335STSwu9hST4vcMRppEPgENMHD2r1REK, (*9)

The Versions

02/12 2017

dev-master

9999999-dev https://github.com/php-mock/php-mock-prophecy

Mock built-in PHP functions (e.g. time()) with Prophecy. This package relies on PHP's namespace fallback policy. No further extension is needed.

  Sources   Download

WTFPL

The Requires

 

The Development Requires

bdd tdd test mock stub test double function prophecy

13/05 2016

0.0.2

0.0.2.0 https://github.com/php-mock/php-mock-prophecy

Mock built-in PHP functions (e.g. time()) with Prophecy. This package relies on PHP's namespace fallback policy. No further extension is needed.

  Sources   Download

WTFPL

The Requires

 

The Development Requires

bdd tdd test mock stub test double function prophecy

16/02 2016

0.0.1

0.0.1.0 https://github.com/php-mock/php-mock-prophecy

Mock built-in PHP functions (e.g. time()) with Prophecy. This package relies on PHP's namespace fallback policy. No further extension is needed.

  Sources   Download

WTFPL

The Requires

 

The Development Requires

bdd tdd test mock stub test double function prophecy