hautelook/frankenstein

The creature that is summoned by mixing PHPUnit, Prophecy, Atoum.

This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.

Maintainers

👁 AdrienBrault

Package info

github.com/hautelook/frankenstein

pkg:composer/hautelook/frankenstein

Statistics

Installs: 3 243

Dependents: 2

Suggesters: 0

Stars: 22

Open Issues: 2

0.1.2 2014-06-03 04:34 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 4c692f408683a8f087a49f43952c999787839953

  • Adrien Brault <adrien.brault.woop@gmail.com>

This package is not auto-updated.

Last update: 2022-01-17 01:54:07 UTC


README

👁 Build Status
👁 Scrutinizer Quality Score
👁 Latest Unstable Version

This let you use PHPUnit with Prophecy mocks and Atoum asserters.

Usage

Your test class must extend Hautelook\Frankenstein\TestCase:

<?php

namespace AcmeDemoBundle\Tests\Foo;

use Hautelook\Frankenstein\TestCase;

class BarTest extends TestCase
{

}

When extending from the provided TestCase everything else than Atoum asserters and Prophecy mocks are restricted.

You will have to use Prophecy to mock, using $this->prophesize():

public function test()
{
 $routerProphecy = $this->prophesize('Symfony\Component\Routing\Generator\UrlGeneratorInterface');
 $routerProphecy
 ->generate('acme_demo_index')
 ->willReturn('/acme')
 ;

 $foo = new Foo($routerProphecy->reveal());
}

You will have to use atoum asserters instead of phpunit's:

public function test()
{
 $foo = new Foo();

 $this
 ->string($foo->getName())
 ->isEqualTo('foo foo foo')
 ;
}

Prophecy arguments

The test class let you access the Prophecy\Argument shortcut methods through $this->arg or $this->arg():

public function test()
{
 $routerProphecy = $this->prophesize('Symfony\Component\Routing\Generator\UrlGeneratorInterface');
 $routerProphecy
 ->generate($this->arg->type('string'))
 ->willReturn('/acme')
 ;

 $foo = new Foo($routerProphecy->reveal());
}

Running the Tests

Install the Composer dev dependencies:

php composer.phar install

Then, run the test suite using phpunit:

bin/phpunit

License

Frankenstein is released under the MIT License. See the bundled LICENSE file for details.

Credits

This library has copies of code https://github.com/atoum/atoum and uses https://github.com/phpspec/prophecy-phpunit .