jacobstr/esperance
Composer 安装命令:
composer require jacobstr/esperance
包简介
BDD style assertion library for PHP.
关键字:
README 文档
README
BDD style assertion library for PHP.
Heavily inspired by expect.js.
Usage
Installation
Espérance can be installed using Composer.
At first, save below as composer.json at the root of your project.
{
"require": {
"esperance/esperance": "dev-master"
}
}
And run these commands.
$ wget http://getcomposer.org/composer.phar
$ php composer.phar install
Then Espérance would be installed in ./vendor directory and also ./vendor/autoload.php is generated.
Very minimal testing script by hand
Just define your expect method or function to construt Esperance\Assertion object.
<?php require './vendor/autoload.php'; function expect($obj) { return new \Esperance\Assertion($obj); } expect(1)->to->be(1); echo "All tests passed.", PHP_EOL;
PHPUnit integrtion
Use esperance/esperance-phpunit.
Extension
Extension using event dispatcher is available.
Events
- before_assertion
\Esperance\Assertion->beforeAssertion($callback) - assertion_success
\Esperance\Assertion->onAssertionSuccess($callback) - assertion_failure
\Esperance\Assertion->onAssertionFailure($callback)
Usage
Assertion counter example.
<?php require './vendor/autoload.php'; $count = $success = $failure = 0; function expect($subject) { global $count, $success, $failure; $extension = new \Esperance\Extension; $extension->beforeAssertion(function () use (&$count) { $count++; }); return new \Esperance\Assertion($subject, $extension); } expect(NULL)->to->be(NULL); expect(0)->to->be(0); expect(1)->to->be(1); echo "Count: {$count}", PHP_EOL; // => Count: 3
License
The MIT License
Author
Yuya Takeyama
统计信息
- 总下载量: 30.81k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-05-25