From f897bc66de5a77bbd9ce8a1537a80c447c8e948b Mon Sep 17 00:00:00 2001 From: Dave Earley Date: Wed, 27 Apr 2016 00:08:27 +0100 Subject: [PATCH] began setting up test env --- .gitignore | 1 + database/factories/ModelFactory.php | 6 ++--- .../2014_03_26_180116_create_users_table.php | 2 +- phpunit.xml | 2 ++ tests/TestCase.php | 25 +++++++++++++++++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index e106f359..66f097c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.env.testing /.phpstorm.meta.php /vendor /node_modules diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 2dca9f36..84560642 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -108,7 +108,7 @@ $factory->define(App\Models\Account::class, function (Faker\Generator $faker) { $factory->define(App\Models\User::class, function (Faker\Generator $faker) { return [ - 'account_id' => $faker->randomDigit, + 'account_id' => factory(App\Models\Account::class)->create()->id, 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'phone' => $faker->phoneNumber, @@ -270,7 +270,7 @@ $factory->define(App\Models\Attendee::class, function (Faker\Generator $faker) { ]; }); -$faker->define(App\Models\Message::class, function (Faker\Generator $faker) { +$factory->define(App\Models\Message::class, function (Faker\Generator $faker) { return [ 'message' => $faker->text, 'subject' => $faker->text, @@ -279,7 +279,7 @@ $faker->define(App\Models\Message::class, function (Faker\Generator $faker) { ]; }); -$faker->define(App\Models\EventImage::class, function (Faker\Generator $faker) { +$factory->define(App\Models\EventImage::class, function (Faker\Generator $faker) { return [ 'image_path' => $faker->imageUrl(), 'event_id' => factory(App\Models\Event::class)->create()->id, diff --git a/database/migrations/2014_03_26_180116_create_users_table.php b/database/migrations/2014_03_26_180116_create_users_table.php index 7d099e5d..5fae282a 100644 --- a/database/migrations/2014_03_26_180116_create_users_table.php +++ b/database/migrations/2014_03_26_180116_create_users_table.php @@ -214,7 +214,7 @@ class CreateUsersTable extends Migration $t->text('post_order_display_message')->nullable(); - $t->text('social_share_text')->default('Check Out [event_title] - [event_url]'); + $t->text('social_share_text')->nullable(); $t->boolean('social_show_facebook')->default(true); $t->boolean('social_show_linkedin')->default(true); $t->boolean('social_show_twitter')->default(true); diff --git a/phpunit.xml b/phpunit.xml index 08522be9..82b12069 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -18,5 +18,7 @@ + + diff --git a/tests/TestCase.php b/tests/TestCase.php index ec09938f..268d1045 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,4 +1,7 @@ loadEnvironmentFrom('.env.testing'); $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); return $app; } + + public function setUp(){ + parent::setUp(); + + \Artisan::call('migrate'); + if (Timezone::count() == 0) { + \Artisan::call('db:seed', ['--force' => true]); + } + + factory(App\Models\User::class)->create([ + 'email' => 'email@email.com', + 'password' => Hash::make('password'), + ]); + + + } + + public function tearDown(){ + parent::tearDown(); + } + } \ No newline at end of file