Skip to content

Commit

Permalink
Switched seeders over to using model factories, switched queue test t…
Browse files Browse the repository at this point in the history
…o use model factory
  • Loading branch information
zakhenry committed Jun 26, 2015
1 parent c14a731 commit 4baca68
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 51 deletions.
38 changes: 0 additions & 38 deletions api/app/Models/TestEntity.php
Expand Up @@ -48,42 +48,4 @@ public function entityRoute()
return '/test/entities';
}

/**
* Generate fake user
* @param array $overrides
* @param null $seed
* @return TestEntity
*/
public static function fakeTestEntity($overrides = [], $seed = null){

$faker = Faker::create('au_AU');;

if ($seed){
$faker->seed($seed);
}

$testEntityInfo = array_merge([

'entity_id' => $faker->uuid,
'varchar' => $faker->word,
'hash' => Hash::make($faker->randomDigitNotNull),
'integer' => $faker->numberBetween(0, 500),
'decimal' => $faker->randomFloat(2, 0, 100),
'boolean' => $faker->boolean(),
'nullable' => null,
'text' => $faker->paragraph(3),
'date' => $faker->date(),
'multi_word_column_title' => true,
'hidden' => $faker->boolean()

], $overrides);

$testEntity = new TestEntity($testEntityInfo);

$testEntity->timestamps = true;
$testEntity->save();

return $testEntity;

}
}
6 changes: 1 addition & 5 deletions api/database/seeds/TestEntitySeeder.php
Expand Up @@ -13,11 +13,7 @@ class TestEntitySeeder extends Seeder {
public function run()
{

foreach(range(0, 20) as $index){

TestEntity::fakeTestEntity();

}
factory(App\Models\TestEntity::class, 20)->create();

}

Expand Down
9 changes: 2 additions & 7 deletions api/database/seeds/UserStorySeeder.php
Expand Up @@ -12,16 +12,11 @@ class UserStorySeeder extends Seeder {
*/
public function run()
{

User::fakeUser([
factory(App\Models\User::class)->create([
'email'=>'john.smith@example.com'
]);

foreach(range(0, 99) as $index){

User::fakeUser();

}
factory(App\Models\User::class, 99)->create();

}

Expand Down
2 changes: 1 addition & 1 deletion api/tests/json/QueueTest.php
Expand Up @@ -17,7 +17,7 @@ public function testQueue()

Queue::push(function($job){

TestEntity::fakeTestEntity();
factory(App\Models\TestEntity::class)->create();

$job->delete();
});
Expand Down

0 comments on commit 4baca68

Please sign in to comment.