tomzx/ditto

Specification-oriented BDD helpers for PHPUnit

v0.2.0 2015-09-19 04:51 UTC

This package is auto-updated.

Last update: 2024-12-12 05:54:20 UTC


README

License Latest Stable Version Latest Unstable Version Build Status Code Quality Code Coverage Total Downloads

What is Ditto?

Ditto is a simple wrapper around PHPUnit assertions which allows developers to use a syntax similar to the one provided by phpspec matchers. With it, you can replace your calls to assertSame, assertEquals and assertInstanceOf.

Usage

use Ditto\Ditto as d;

// Before PHP 5.5
$ditto = d::make('SomeClass');
// As of PHP 5.5
$ditto = d::make(SomeClass::class);

$ditto->someMethod()->shouldReturn('some value');

// ===
$ditto->someMethod()->shouldReturn('some value');
$ditto->someMethod()->shouldBe('some value');
$ditto->someMethod()->shouldEqual('some value');
$ditto->someMethod()->shouldBeEqualTo('some value');

// ==
$ditto->someMethod()->shouldBeLike('some value');

// instanceof
$ditto->someMethod()->shouldHaveType('SomeType');
$ditto->someMethod()->shouldReturnAnInstanceOf('SomeType');
$ditto->someMethod()->shouldBeAnInstance('SomeType');
$ditto->someMethod()->shouldImplement('SomeType');

// It also works on intrinsic values
$ditto = d::make('this is nice');
$ditto->shouldReturn('this is nice');

$ditto = d::make(15);
$ditto->shouldBe(15);

Contributing to Ditto

All issues and pull requests should be filed on the tomzx/ditto repository.

License

The code is licensed under the MIT license. See LICENSE.