noonat/pecs

此软件包最新版本(dev-master)没有提供许可信息。

dev-master 2013-01-08 17:27 UTC

This package is not auto-updated.

Last update: 2024-09-22 02:24:02 UTC


README

pecs 是一个针对 PHP 5.3 的小型行为驱动开发库,类似于 RSpecJSpec

要使用传统的示例,它的工作方式如下

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 测试之间切换时需要频繁转换思路。

贡献者

待办事项

  • 添加 beforeafter 钩子
  • 需要添加更多匹配器
  • 需要改进失败输出

许可

(MIT 许可证)

版权 ©2009 noonat

在此,任何人获取此软件及其相关文档文件(以下简称“软件”)的副本,均免费获得在此软件上不受限制地处理软件的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,并允许向软件提供者提供软件的人这样做,前提是必须遵守以下条件

上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。

本软件按“原样”提供,不提供任何形式的保证,无论是明示的、暗示的,包括但不限于适销性、特定目的的适用性和非侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论该责任是基于合同、侵权或其他法律,无论该责任是否源自、因之而起或与此软件或软件的使用或其他交易有关。