hautelook / frankenstein
由 PHPUnit、Prophecy、Atoum 混合召唤的生物。
该软件包的官方仓库似乎已不存在,因此该软件包已被冻结。
0.1.2
2014-06-03 04:34 UTC
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
让您可以使用 Prophecy 模拟和 Atoum 断言与 PHPUnit 一起使用。
使用方法
您的测试类必须扩展 Hautelook\Frankenstein\TestCase
<?php namespace AcmeDemoBundle\Tests\Foo; use Hautelook\Frankenstein\TestCase; class BarTest extends TestCase { }
当从提供的 TestCase
扩展时,除了 Atoum 断言和 Prophecy 模拟之外的内容都将被限制。
您将需要使用 Prophecy 来模拟,使用 $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()); }
您将需要使用 atoum 断言而不是 phpunit 的
public function test() { $foo = new Foo(); $this ->string($foo->getName()) ->isEqualTo('foo foo foo') ; }
Prophecy 参数
测试类允许您通过 $this->arg
或 $this->arg()
访问 Prophecy\Argument
快捷方法。
public function test() { $routerProphecy = $this->prophesize('Symfony\Component\Routing\Generator\UrlGeneratorInterface'); $routerProphecy ->generate($this->arg->type('string')) ->willReturn('/acme') ; $foo = new Foo($routerProphecy->reveal()); }
运行测试
安装 Composer 的 dev
依赖项
php composer.phar install
然后,使用 phpunit 运行测试套件
bin/phpunit
许可证
Frankenstein 在 MIT 许可证下发布。有关详细信息,请参阅附带 LICENSE 文件。
致谢
此库包含来自 https://github.com/atoum/atoum 的代码副本,并使用 https://github.com/phpspec/prophecy-phpunit。