2017 © Pedro Peláez
 

library pest

A php unit testing library with Rspec style

image

acro5piano/pest

A php unit testing library with Rspec style

  • Friday, April 27, 2018
  • by acro5piano
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Pest

A php unit testing library with Rspec style., (*1)

[Under developing], (*2)

Example

use Acro5piano\Pest\Spec;

function add(int $x, int $y)
{
    return $x + $y;
}

Spec::describe('add', function ($it) {
    $it('returns 3 given 1, 2', function ($expect) {
        $expect(add(1, 2))->toBe(3);
    });
    $it('a failing test', function ($expect) {
        $expect(add(1, 2))->toBe(4);
    });
});

Result:, (*3)

image, (*4)

Documentation

Install

composer require --dev acro5piano/pest

Grouping

You can nest with Type Hint., (*5)

use Acro5piano\Pest\Describe;

Spec::describe('1: first describe', function (Describe $describe) {
    $describe('2: second describe', function ($it) {
        $it('3: finally it comes', function ($expect) {
            $expect([1, 2])->not()->toContain(1);
        });
    });
});

Result:, (*6)

Failed
  1: first describe
      2: second describe
            3: finally it comes

Assertions

  • toBe
  • toContain

not() invert the condition. e.g.), (*7)

$expect([1, 2])->not()->toContain(3); // -> Fails

The Versions

27/04 2018

dev-master

9999999-dev

A php unit testing library with Rspec style

  Sources   Download

MIT

The Development Requires

by gosho-kazuya