php mockery单元测试,Mockery:一个简单而灵活的PHP框架模拟对象,用于在PHPUnit中进行单元测试...

Mockery

0f23167ffb98daab9365808916f0dbbf.png68747470733a2f2f706f7365722e707567782e6f72672f6d6f636b6572792f6d6f636b6572792f762f737461626c652e706e6768747470733a2f2f706f7365722e707567782e6f72672f6d6f636b6572792f6d6f636b6572792f646f776e6c6f6164732e706e67

Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.

Mockery is released under a New BSD License.

The current released version on Packagist is 0.9.5. Composer users may opt to use 0.9.* for the current stable package, or ~1.0@dev for the current master branch. Latest version released through PEAR was 0.9.0; channel is now closed.

Installation

To install Mockery, run the command below and you will get the latest version

composer require --dev mockery/mockery

If you want to run the tests:

vendor/bin/phpunit

Note

The current Mockery 0.9.5 release is the final version to have PHP 5.3 as a minimum requirement. The minimum PHP requirement has been moved to PHP 5.4 for future releases. Also, the PEAR channel has gone offline permanently since 30 June 2015.

Mock Objects

In unit tests, mock objects simulate the behaviour of real objects. They are commonly utilised to offer test isolation, to stand in for objects which do not yet exist, or to allow for the exploratory design of class APIs without requiring actual implementation up front.

The benefits of a mock object framework are to allow for the flexible generation of such mock objects (and stubs). They allow the setting of expected method calls and return values using a flexible API which is capable of capturing every possible real object behaviour in way that is stated as close as possible to a natural language description.

Prerequisites

Mockery requires PHP 5.3.2 or greater for versions 0.9.5 or lower. The current master and future versions are using PHP 5.4 at minimum. This is subject to change as PHP versions reach their published end of life dates.

Documentation

The current version can be seen at docs.mockery.io.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值