2017 © Pedro Peláez
 

library fuzzymock

image

timg/fuzzymock

  • Friday, June 22, 2018
  • by timglabisch
  • Repository
  • 2 Watchers
  • 5 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 200 % Grown

The README.md

fuzzmock

composer require timg/fuzzymock

Fuzzymock is a small library that helps to create tests for edge-cases., (*1)

Sometimes you want to check if 2 different implementations that are using such a class are working the same way. Something like:, (*2)

static::assertEquals((new GreeterA)->greet($person), (new GreeterB)->greet($person));

consider you've such a Person class:, (*3)


class Person { public $age; public function getAge() { return $this->age; } }

you can create a FuzzyMock for the Person:, (*4)


$fuzzyPersonMock = new \Tg\Fuzzymock\FuzzyBuilder(Person::class); $fuzzyPersonMock->fn('getAge') ->couldReturn(new FuzzyFloat(1, 2, 2)) ->couldReturn(new FuzzyCastString(new FuzzyInt())) ; /** @var Person $person */ $personBuilder = $fuzzyPersonMock->createBuilder(); while (true) { $person = $personBuilder->createNew(); echo $person->getAge() . "\n"; // a float, or a string containing a random int }

the createBuilder method creates a PHP-Class on the fly (no reflection etc.). currently there are no benchmarks but FuzzyMock should be extrem fast., (*5)

The Versions

22/06 2018

dev-master

9999999-dev

  Sources   Download

MIT

by Avatar timglabisch