alsbury / malice
Symfony 扩展包和 Codeception 固定数据模块
0.2.1
2016-07-14 20:46 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- codeception/codeception: ^2.1
- hautelook/alice-bundle: ~1.2.0
- nelmio/alice: ~2.1
- symfony/finder: ^2.7|~3.0
This package is not auto-updated.
Last update: 2024-09-14 19:36:57 UTC
README
用于与 AliceBundle 一起使用 Alice/Faker 固定数据的 Codeception 模块。
这是一个早期原型。欢迎提供反馈。
安装
composer require alsbury/malice
配置 Codeception 测试套件
将模块添加到 codeception 测试套件 YAML 文件中
class_name: FunctionalTester
modules:
enabled:
- Symfony2:
app_path: '../../../app'
var_path: '../../../var'
environment: 'test'
- \Component\Registration\Tests\Helper\Functional
- \Alsbury\Malice\Component\Codeception\Module\Malice:
drop_create: true
示例测试,加载由 Doctrine 注解指定的扩展包中定义的固定数据
<?php
use Alsbury\Malice\Component\Annotation\Fixture;
/**
* @Fixture("MyBundle:Foo.yml")
* @Fixture("MyBundle:Bar.yml")
* @Fixture("AnotherBundle:AnotherFoo.yml")
*/
class AccountCreatorTest extends \Codeception\TestCase\Test
{
/**
* @Fixture("MyBundle:MethodSpecificFoo.yml")
*/
public function testNothing()
{
$this->assertEquals(true, true);
}
public function testSomeOtherNothing()
{
$this->assertEquals(true,true);
}
}
按照 hautelook/alice-bundle
规范设置固定数据。固定数据定义文件 Foo.yml
预期位于特定扩展包目录中的 DataFixtures/ORM
目录。每个固定数据都需要像上面示例中那样有自己的注解,包含扩展包名称,后跟冒号,然后是固定数据 yaml 文件名 MyBundle:Foo.yml
。类级别的固定数据注解将应用于该类中的所有方法。方法级别的固定数据注解将仅添加到特定测试的类固定数据中。
当前不支持固定数据环境。
需求
- Symfony 2 或 3
- Codeception 2.1+ 以及 Symfony 2 模块
- hautelook/alice-bundle