From 1fd7a7169d48f8ea031097b573bf3b3a7826acb3 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 19 Jul 2017 15:10:17 +0800 Subject: [PATCH] Pass all test suite with migrate and seed --- database/factories/ModelFactory.php | 10 +--------- .../2016_07_08_182606_create_subscriptions_table.php | 2 +- routes/web.php | 2 +- tests/TestCase.php | 1 - tests/api/ApiEventsTest.php | 2 +- tests/api/ApiManageProjectsTest.php | 2 +- tests/auth/ManageUsersTest.php | 2 +- tests/auth/MemberChangePasswordTest.php | 2 +- tests/auth/MemberRegistrationAndLoginTest.php | 6 +++--- tests/auth/MemberResetPasswordTest.php | 2 +- tests/functional/ManageFeaturesTest.php | 2 +- tests/functional/ManagePaymentsTest.php | 2 +- tests/functional/ManageProjectsTest.php | 10 ---------- tests/functional/ManageSubscriptionsTest.php | 6 +++--- tests/functional/ManageTasksTest.php | 2 +- 15 files changed, 17 insertions(+), 36 deletions(-) diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 30ebbfb..2972fd8 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -13,21 +13,13 @@ $factory->define(User::class, function (Faker\Generator $faker) { return [ 'name' => $faker->name, 'username' => $faker->unique()->username, - 'email' => $email = $faker->unique()->email, + 'email' => $faker->unique()->email, 'password' => 'member', 'remember_token' => str_random(10), 'api_token' => str_random(40), ]; }); -$factory->define(Role::class, function (Faker\Generator $faker) { - return [ - 'type' => 0, - 'name' => $faker->word, - 'label' => $faker->sentence, - ]; -}); - $factory->define(Project::class, function (Faker\Generator $faker) { $proposalDate = $faker->dateTimeBetween('-1 year', '-1 month')->format('Y-m-d'); diff --git a/database/migrations/2016_07_08_182606_create_subscriptions_table.php b/database/migrations/2016_07_08_182606_create_subscriptions_table.php index c232626..d5bd859 100644 --- a/database/migrations/2016_07_08_182606_create_subscriptions_table.php +++ b/database/migrations/2016_07_08_182606_create_subscriptions_table.php @@ -22,7 +22,7 @@ class CreateSubscriptionsTable extends Migration { $table->string('epp_code', 60)->nullable(); $table->integer('domain_price')->unsigned(); $table->string('hosting_capacity', 60)->nullable(); - $table->boolean('status_id')->default(1); + $table->boolean('status_id')->unsigned()->default(1); $table->integer('hosting_price')->unsigned()->nullable(); $table->date('start_date')->nullable(); $table->date('due_date')->nullable(); diff --git a/routes/web.php b/routes/web.php index 7542305..7214f73 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,5 +1,5 @@ loginUsingId(1); +// auth()->loginUsingId(1); require __DIR__ . '/web/helpers.php'; require __DIR__ . '/web/pages.php'; diff --git a/tests/TestCase.php b/tests/TestCase.php index 0e46e14..3f96d3f 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -29,7 +29,6 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase protected function adminUserSigningIn() { - factory(Role::class)->create(['name' => 'admin']); $user = factory(User::class)->create(); $user->assignRole('admin'); $this->actingAs($user); diff --git a/tests/api/ApiEventsTest.php b/tests/api/ApiEventsTest.php index 464e105..40d03ad 100644 --- a/tests/api/ApiEventsTest.php +++ b/tests/api/ApiEventsTest.php @@ -8,7 +8,7 @@ use Illuminate\Foundation\Testing\WithoutMiddleware; class ApiEventsTest extends TestCase { - use DatabaseTransactions; + use DatabaseMigrations; /** @test */ public function it_can_get_all_existing_events() diff --git a/tests/api/ApiManageProjectsTest.php b/tests/api/ApiManageProjectsTest.php index 4a584f2..16a2c65 100644 --- a/tests/api/ApiManageProjectsTest.php +++ b/tests/api/ApiManageProjectsTest.php @@ -8,7 +8,7 @@ use Illuminate\Foundation\Testing\WithoutMiddleware; class ApiManageProjectsTest extends TestCase { - use DatabaseTransactions; + use DatabaseMigrations; /** @test */ public function user_can_get_project_lists() diff --git a/tests/auth/ManageUsersTest.php b/tests/auth/ManageUsersTest.php index 27e9bfd..a655860 100644 --- a/tests/auth/ManageUsersTest.php +++ b/tests/auth/ManageUsersTest.php @@ -7,7 +7,7 @@ use Illuminate\Foundation\Testing\WithoutMiddleware; class ManageUsersTest extends TestCase { - use DatabaseTransactions; + use DatabaseMigrations; /** @test */ public function admin_can_insert_new_user() diff --git a/tests/auth/MemberChangePasswordTest.php b/tests/auth/MemberChangePasswordTest.php index a73d8a9..8768bdb 100644 --- a/tests/auth/MemberChangePasswordTest.php +++ b/tests/auth/MemberChangePasswordTest.php @@ -7,7 +7,7 @@ use Illuminate\Foundation\Testing\WithoutMiddleware; class MemberChangePasswordTest extends TestCase { - use DatabaseTransactions; + use DatabaseMigrations; /** @test */ public function member_can_change_password() diff --git a/tests/auth/MemberRegistrationAndLoginTest.php b/tests/auth/MemberRegistrationAndLoginTest.php index 00eede0..680b034 100644 --- a/tests/auth/MemberRegistrationAndLoginTest.php +++ b/tests/auth/MemberRegistrationAndLoginTest.php @@ -7,13 +7,13 @@ use Illuminate\Foundation\Testing\WithoutMiddleware; class MemberRegistrationAndLoginTest extends TestCase { - use DatabaseTransactions; + use DatabaseMigrations; /** @test */ public function registration_validation() { - $user = factory(User::class)->create(['email' => 'member@app.dev']); - $user->assignRole('customer'); + // $user = factory(User::class)->create(['email' => 'member@app.dev']); + // $user->assignRole('customer'); $this->visit(route('auth.register')); $this->type('', 'name'); diff --git a/tests/auth/MemberResetPasswordTest.php b/tests/auth/MemberResetPasswordTest.php index aa9621d..4072189 100644 --- a/tests/auth/MemberResetPasswordTest.php +++ b/tests/auth/MemberResetPasswordTest.php @@ -6,7 +6,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions; class MemberResetPasswordTest extends TestCase { - use DatabaseTransactions; + use DatabaseMigrations; /** @test */ public function member_can_reset_password_by_their_email() diff --git a/tests/functional/ManageFeaturesTest.php b/tests/functional/ManageFeaturesTest.php index 36d322f..5362f42 100644 --- a/tests/functional/ManageFeaturesTest.php +++ b/tests/functional/ManageFeaturesTest.php @@ -10,7 +10,7 @@ use Illuminate\Foundation\Testing\WithoutMiddleware; class ManageFeaturesTest extends TestCase { - use DatabaseTransactions; + use DatabaseMigrations; /** @test */ public function admin_can_entry_feature() diff --git a/tests/functional/ManagePaymentsTest.php b/tests/functional/ManagePaymentsTest.php index f22bb44..5f9793e 100644 --- a/tests/functional/ManagePaymentsTest.php +++ b/tests/functional/ManagePaymentsTest.php @@ -9,7 +9,7 @@ use Illuminate\Foundation\Testing\WithoutMiddleware; class ManagePaymentsTest extends TestCase { - use DatabaseTransactions; + use DatabaseMigrations; /** @test */ public function admin_can_entry_project_a_cashin_payment() diff --git a/tests/functional/ManageProjectsTest.php b/tests/functional/ManageProjectsTest.php index b6002f2..d636fb2 100644 --- a/tests/functional/ManageProjectsTest.php +++ b/tests/functional/ManageProjectsTest.php @@ -17,9 +17,6 @@ class ManageProjectsTest extends TestCase /** @test */ public function admin_can_input_new_project_with_existing_customer() { - $adminRole = factory(Role::class)->create(['name' => 'admin']); - $customerRole = factory(Role::class)->create(['name' => 'customer']); - $users = factory(User::class, 2)->create(); $users[0]->assignRole('admin'); $this->actingAs($users[0]); @@ -46,7 +43,6 @@ class ManageProjectsTest extends TestCase public function admin_can_input_new_project_with_new_customer() { $this->adminUserSigningIn(); - $customerRole = factory(Role::class)->create(['name' => 'customer']); $this->visit(route('projects.index')); $this->seePageIs(route('projects.index')); @@ -112,9 +108,6 @@ class ManageProjectsTest extends TestCase /** @test */ public function admin_can_edit_a_project() { - $adminRole = factory(Role::class)->create(['name' => 'admin']); - $customerRole = factory(Role::class)->create(['name' => 'customer']); - $users = factory(User::class, 2)->create(); $users[0]->assignRole('admin'); $this->actingAs($users[0]); @@ -150,9 +143,6 @@ class ManageProjectsTest extends TestCase /** @test */ public function form_is_validated_on_invalid_project_entry() { - $adminRole = factory(Role::class)->create(['name' => 'admin']); - $customerRole = factory(Role::class)->create(['name' => 'customer']); - $users = factory(User::class, 2)->create(); $users[0]->assignRole('admin'); $this->actingAs($users[0]); diff --git a/tests/functional/ManageSubscriptionsTest.php b/tests/functional/ManageSubscriptionsTest.php index 48c6436..0c5d844 100644 --- a/tests/functional/ManageSubscriptionsTest.php +++ b/tests/functional/ManageSubscriptionsTest.php @@ -9,7 +9,7 @@ use Illuminate\Foundation\Testing\WithoutMiddleware; class ManageSubscriptionsTest extends TestCase { - use DatabaseTransactions; + use DatabaseMigrations; /** @test */ public function admin_can_entry_subscription() @@ -88,7 +88,7 @@ class ManageSubscriptionsTest extends TestCase $this->select($project->id, 'project_id'); $this->select($customer->id, 'customer_id'); $this->select($vendor->id, 'vendor_id'); - $this->select(0,'status_id'); + $this->select(1,'status_id'); $this->press(trans('subscription.update')); $this->seePageIs('subscriptions/' . $subscription->id . '/edit'); @@ -97,7 +97,7 @@ class ManageSubscriptionsTest extends TestCase 'epp_code' => $eppCode, 'customer_id' => $customer->id, 'project_id' => $project->id, - 'status_id' => 0, + 'status_id' => 1, 'hosting_capacity' => '4GB', 'hosting_price' => '500000', 'start_date' => '2015-05-02', diff --git a/tests/functional/ManageTasksTest.php b/tests/functional/ManageTasksTest.php index b0a168f..8045cdb 100644 --- a/tests/functional/ManageTasksTest.php +++ b/tests/functional/ManageTasksTest.php @@ -10,7 +10,7 @@ use Illuminate\Foundation\Testing\WithoutMiddleware; class ManageTasksTest extends TestCase { - use DatabaseTransactions; + use DatabaseMigrations; /** @test */ public function admin_can_entry_task()