php-mock/php-mock-prophecy 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

php-mock/php-mock-prophecy

最新稳定版本:0.1.4

Composer 安装命令:

composer require --dev 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.

README 文档

README

This package integrates the function mock library PHP-Mock with Prophecy.

Installation

Use Composer:

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

Usage

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

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:

  • 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.

  • 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.

  • 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).

License and authors

This project is free and under the WTFPL. Responsable for this project is Markus Malkusch markus@malkusch.de.

Donations

If you like this project and feel generous donate a few Bitcoins here: 1335STSwu9hST4vcMRppEPgENMHD2r1REK

统计信息

  • 总下载量: 450.85k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 16
  • 点击次数: 1
  • 依赖项目数: 15
  • 推荐数: 0

GitHub 信息

  • Stars: 16
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: WTFPL
  • 更新时间: 2015-10-31