rstuven / pecs
此包的最新版本(dev-master)没有可用的许可信息。
dev-master
2012-03-20 14:20 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-22 02:16:47 UTC
README
pecs 是一个用于 PHP 5.3 的小型行为驱动开发库,类似于 RSpec 或 JSpec。
使用传统示例,它的工作方式如下
require "lib/pecs.php";
require "bowling.php";
describe("Bowling", function() {
it("should score 0 for a gutter game", function() {
$bowling = new Bowling();
for ($i=0; $i < 20; $i++) {
$bowling->hit(0);
}
expect($bowling->score)->to_equal(0);
});
it("should get drinks for free just for being here", function() {
$bowling = new Bowling();
expect($bowling->score)->to_equal(42);
});
});
\pecs\run();
输出看起来像这样
$ php test_bowling.php
Bowling
- should score 0 for a gutter game: pass
- should get drinks for free just for being here: fail
FAILURE:
expected 0 to equal 42
#0 .../lib/pecs.php(32): pecs\Expect->assert('_equal', Array, true)
#1 [internal function]: pecs\Expect->__call('to_equal', Array)
#2 .../test_bowling.php(15): pecs\Expect->to_equal(42)
#3 .../lib/pecs.php(221): {closure}()
#4 .../lib/pecs.php(192): pecs\Spec->run()
#5 .../lib/pecs.php(195): pecs\Suite->run()
#6 .../lib/pecs.php(195): pecs\Suite->run()
#7 .../lib/pecs.php(262): pecs\Suite->run()
#8 .../lib/pecs.php(350): pecs\Runner->run(NULL)
#9 .../test_bowling.php(19): pecs\run()
#10 {main}
Finished in 0.0017 seconds
Passed: 1 Failed: 1
致谢
pecs 受 JSpec 的无语法语法启发,并被编写出来,因为我不想在 PHP 和 JSpec 测试之间切换时那么频繁地转换方向。
待办事项
- 添加
before
和after
钩子 - 需要一个脚本来运行测试文件夹
- 需要添加更多匹配器
- 需要改进失败输出
许可
(MIT 许可证)
版权所有 ©2009 noonat
在此协议下,任何人免费获得本软件及其相关文档副本(“软件”),可以在不受限制的情况下处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本,并允许向软件提供者提供软件的人这样做,前提是遵守以下条件
上述版权声明和本许可声明应包含在软件的任何副本或实质性部分中。
软件按“现状”提供,不提供任何明示或暗示的保证,包括但不限于适销性、适用于特定目的和无侵犯性的保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论这些责任是基于合同、侵权或其他方式,源于、因之或与此软件或其使用或其他交易有关。