foothing/laravel-fixture
最新稳定版本:v0.1.0
Composer 安装命令:
composer require foothing/laravel-fixture
包简介
Lightweight fixtures for Laravel 4
README 文档
README
Basic light-weight fixtures management for Laravel 4.
How to use
Setup the tearDown() in your test cases
public function tearDown() { // Your code // ... Fixture::tearDown(); }
Usage of Fixture::need()
class FooTest { public function testBar() { // Create your fixture by passing the namespaced class name // you want to fixture and an array of attributes. // If an User instance matching the given attributes is found, // then it will be returned. Otherwise a new User instance will be // saved to the testing database. // Note that User must be an Eloquent implementation. $user = Fixture::need('User', array('email' => 'email1')); // Example, $user now exists with the given attributes. $this->assertEquals($user->email, 'email1'); // ... // more tests. } }
You'll want to use the need method when your test requires a given instance.
Usage of Fixture::needNot()
class FooTest { public function testBar() { // Ensure that no instances of Some\Object matching the given // attributes are stored in the testing database. Fixture::needNot('Some\Object', array('attribute' => 'value')); } }
You'll use this when your test requires that your database is clean before running.
This may save you some time since you can have a fine data setup instead of running migrations that slower down test execution time.
Note that Fixture is not a Facade, so you don't need to configure any service provider.
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2014-12-09