2017 © Pedro PelĂĄez
 

library esperance

BDD style assertion library for PHP.

image

esperance/esperance

BDD style assertion library for PHP.

  • Saturday, July 7, 2012
  • by yuya-takeyama
  • Repository
  • 0 Watchers
  • 9 Stars
  • 5,558 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Espérance

master: Build Status develop: Build Status, (*1)

BDD style assertion library for PHP., (*2)

Heavily inspired by expect.js., (*3)

Usage

Installation

Espérance can be installed using Composer., (*4)

At first, save below as composer.json at the root of your project., (*5)

{
    "require": {
        "esperance/esperance": "dev-master"
    }
}

And run these commands., (*6)

$ 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., (*7)

Very minimal testing script by hand

Just define your expect method or function to construt Esperance\Assertion object., (*8)

<?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., (*9)

Extension

Extension using event dispatcher is available., (*10)

Events

  • before_assertion \Esperance\Assertion->beforeAssertion($callback)
  • assertion_success \Esperance\Assertion->onAssertionSuccess($callback)
  • assertion_failure \Esperance\Assertion->onAssertionFailure($callback)

Usage

Assertion counter example., (*11)

<?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, (*12)

Author

Yuya Takeyama, (*13)

The Versions

07/07 2012

dev-develop

dev-develop

BDD style assertion library for PHP.

  Sources   Download

MIT

The Requires

 

The Development Requires

bdd tdd assertion

06/07 2012

dev-master

9999999-dev

BDD style assertion library for PHP.

  Sources   Download

MIT

The Requires

 

bdd tdd assertion

06/07 2012

v0.1.0

0.1.0.0

BDD style assertion library for PHP.

  Sources   Download

MIT

The Requires

 

bdd tdd assertion

01/07 2012

v0.0.3

0.0.3.0

BDD style assertion library for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

bdd tdd assertion

01/07 2012

v0.0.2

0.0.2.0

BDD style assertion library for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

bdd tdd assertion

01/07 2012

v0.0.1

0.0.1.0

BDD style assertion library for PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

bdd tdd assertion