2017 © Pedro Peláez
 

library phpunit-object-constraint

image

hshn/phpunit-object-constraint

  • Wednesday, January 17, 2018
  • by hshn
  • Repository
  • 1 Watchers
  • 2 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

phpunit-object-constraint Build Status

PHPUnit helper for explicit object comparison., (*1)

Make it easier to your apps more safety by providing easy object assertion., (*2)

How to use

1. Import helper trait into your class


use Hshn\PHPUnit\Framework\Constraint\ObjectConstraintSupport; class MyTest extends \PHPUnit_Framework_TestCase { use ObjectConstraintSupport; }

2. Build your object constraint using constraint builder


public function test1() { // this constraint means: // property 'foo' start with 'a' and end with 'e' // and property 'bar' is true $constraint = $this->constraintFor(\stdClass::class) ->property('foo') ->stringStartsWith('a') ->stringEndsWith('e') ->property('bar') ->isTrue() ->getConstraint(); }

3. Assert any value with the constraint you built

self::assertThat($value, $constraint);

The Versions

17/01 2018

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

by Shota Hoshino

17/01 2018

v0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

 

by Shota Hoshino