2017 © Pedro Peláez
 

library expect

BDD-style assertions for PHP.

image

jasonmccreary/expect

BDD-style assertions for PHP.

  • Thursday, June 30, 2016
  • by jasonmccreary
  • Repository
  • 0 Watchers
  • 5 Stars
  • 30 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Expect

Build Status Latest Stable Version, (*1)

Expect is a BDD-style assertion library for PHP - allowing you to express expectations using a natural, fluent interface., (*2)

// equality
expect(1)->toEqual('1');
expect(2)->toBe(2);

// comparison
expect(5)->toBeLessThan(7);
expect(5)->toBeLessThanOrEqualTo(5);
expect(5)->toBeGreaterThan(4);
expect(5)->toBeGreaterThanOrEqualTo(5);

// true / false / null
expect(true)->toBeTrue();
expect('1')->toBeTruthy();
expect(false)->toBeFalse();
expect('0')->toBeFalsy();
expect(null)->toBeNull();

// strings
expect('string')->toContain('in');
expect('string')->toStartWith('str');
expect('string')->toEndWith('ing');
expect('string')->toHaveLength(6);
expect('string')->toMatchPattern('/string/');
expect('string')->toMatchFormat('%s');

// arrays
expect(['a', 'b', 'c'])->toHaveCount(3);
expect(['a', 'b', 'c'])->toContain('a');
expect(['key' => 'value'])->toHaveKey('key');

// types
expect(1)->toBeType('int');
expect(new Example())->toBeInstanceOf(Example::class);
expect('{"key": "value"}')->toBeJson();
expect('<key>value</key>')->toBeXml();

// files
expect('file.txt')->toExist();

// negation
expect(1)->not()->toEqual(2);
expect(true)->not()->toBeFalse();
expect($value)->not()->toBeNull();

Installation

Install Expect as a development dependency to your project using Composer:, (*3)

composer require --dev jasonmccreary/expect

Usage

Expect is used by PSpec, but can be used within other PHP testing frameworks or as a stand-alone., (*4)

Documentation

Documentation and additional examples will be available in the official release., (*5)

License

Expect is open-sourced software licensed under the MIT license., (*6)

Thanks

Expect was built atop Verify and heavily inspired by RSpec and Jasmine. I want to recognize and thank these projects., (*7)

The Versions

30/06 2016

dev-master

9999999-dev

BDD-style assertions for PHP.

  Sources   Download

MIT

The Requires

 

by Jason McCreary

bdd test assert matcher

30/06 2016

v1.0.1

1.0.1.0

BDD-style assertions for PHP.

  Sources   Download

MIT

The Requires

 

by Jason McCreary

bdd test assert matcher

30/06 2016

v1.0.0

1.0.0.0

BDD-style assertions for PHP.

  Sources   Download

MIT

The Development Requires

by Jason McCreary

bdd test assert matcher