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.
Installs: 3 243
Dependents: 2
Suggesters: 0
Security: 0
Stars: 22
Watchers: 19
Forks: 0
Open Issues: 2
Requires
- atoum/atoum: 0.0.1
- phpspec/prophecy-phpunit: ~1.0
Requires (Dev)
- phpunit/phpunit: ~3.7
This package is not auto-updated.
Last update: 2022-01-17 01:54:07 UTC
README
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 .