Package Data | |
---|---|
Maintainer Username: | brazorf |
Maintainer Contact: | fabrizio.ranieri@gmail.com (Fabrizio Ranieri) |
Package Create Date: | 2014-12-09 |
Package Last Update: | 2015-02-16 |
Home Page: | |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-10-31 15:19:22 |
Package Statistics | |
---|---|
Total Downloads: | 21 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Basic light-weight fixtures management for Laravel 4.
Setup the tearDown() in your test cases
public function tearDown() {
// Your code
// ...
Fixture::tearDown();
}
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.
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.