From 73bbefd4c50e6bd697e241a070d2f8159cc901f9 Mon Sep 17 00:00:00 2001 From: Mateusz Wojczal Date: Thu, 23 Dec 2021 14:03:14 +0100 Subject: [PATCH] remove settings test from LRS --- tests/API/SettingsAdminTest.php | 182 ----------------------- tests/API/SettingsAnonymousAdminTest.php | 127 ---------------- tests/API/SettingsAnonymousTest.php | 95 ------------ 3 files changed, 404 deletions(-) delete mode 100644 tests/API/SettingsAdminTest.php delete mode 100644 tests/API/SettingsAnonymousAdminTest.php delete mode 100644 tests/API/SettingsAnonymousTest.php diff --git a/tests/API/SettingsAdminTest.php b/tests/API/SettingsAdminTest.php deleted file mode 100644 index 761cf14..0000000 --- a/tests/API/SettingsAdminTest.php +++ /dev/null @@ -1,182 +0,0 @@ -seed(PermissionTableSeeder::class); - $this->seed(DatabaseSeeder::class); - - $this->user = config('auth.providers.users.model')::factory()->create(); - $this->user->guard_name = 'api'; - $this->user->assignRole('admin'); - } - /** - * @test - */ - public function test_admin_fetch() - { - - $this->response = $this->actingAs($this->user, 'api')->json( - 'GET', - '/api/admin/settings' - ); - $this->response->assertOk(); - - $this->response->assertJsonFragment(['data' => ["USD", "EUR"]]); - $this->response->assertJsonFragment(['data' => 'Lorem IPSUM']); - $this->response->assertJsonFragment(['current_page' => 1]); - } - - public function test_admin_fetch_paginate() - { - - $this->response = $this->actingAs($this->user, 'api')->json( - 'GET', - '/api/admin/settings?page=2' - ); - $this->response->assertOk(); - - $this->response->assertJsonFragment(['current_page' => 2]); - } - - public function test_admin_fetch_search() - { - - Setting::firstOrCreate([ - 'group' => 'images', - 'key' => 'tutor', - 'value' => "tutor_avatar.jpg", - 'public' => true, - 'enumerable' => true, - 'type' => 'image' - ]); - - $this->response = $this->actingAs($this->user, 'api')->json( - 'GET', - '/api/admin/settings?group=images' - ); - $this->response->assertOk(); - - $this->response->assertJsonFragment(['group' => 'images']); - } - - public function test_admin_show() - { - - $setting = Setting::first(); - $this->response = $this->actingAs($this->user, 'api')->json( - 'GET', - '/api/admin/settings/' . $setting->id - ); - $this->response->assertOk(); - } - - public function test_not_found_show() - { - - $this->response = $this->actingAs($this->user, 'api')->json( - 'GET', - '/api/admin/settings/9999' - ); - $this->response->assertNotFound(); - } - - public function test_admin_groups() - { - - $setting = Setting::first(); - $this->response = $this->actingAs($this->user, 'api')->json( - 'GET', - '/api/admin/settings/groups' - ); - $this->response->assertOk(); - - $this->assertTrue(in_array($setting->group, $this->response->getData()->data)); - } - - public function test_admin_update() - { - $setting = Setting::first(); - - $input = [ - 'group' => 'config', - 'key' => 'app.env', - 'value' => "app.env", - 'public' => true, - 'enumerable' => true, - 'type' => 'config' - ]; - - $this->response = $this->actingAs($this->user, 'api')->json( - 'PUT', - '/api/admin/settings/' . $setting->id, - $input - ); - - $this->response->assertOk(); - - $this->assertEquals($input['value'], $this->response->getData()->data->value); - - - $this->response = $this->actingAs($this->user, 'api')->json( - 'PUT', - '/api/admin/settings/9999', - $input - ); - $this->response->assertNotFound(); - } - - public function test_admin_create() - { - $input = [ - 'group' => 'config', - 'key' => 'app.env', - 'value' => "app.env", - 'public' => true, - 'enumerable' => true, - 'type' => 'config' - ]; - - $this->response = $this->actingAs($this->user, 'api')->json( - 'POST', - '/api/admin/settings', - $input - ); - - $this->response->assertOk(); - - $this->assertEquals($input['value'], $this->response->getData()->data->value); - } - - public function test_admin_delete() - { - $setting = Setting::first(); - - $this->response = $this->actingAs($this->user, 'api')->json( - 'DELETE', - '/api/admin/settings/' . $setting->id, - ); - - $this->response->assertOk(); - - $this->response = $this->actingAs($this->user, 'api')->json( - 'DELETE', - '/api/admin/settings/' . $setting->id, - ); - - $this->response->assertNotFound(); - } -} diff --git a/tests/API/SettingsAnonymousAdminTest.php b/tests/API/SettingsAnonymousAdminTest.php deleted file mode 100644 index 0bd9811..0000000 --- a/tests/API/SettingsAnonymousAdminTest.php +++ /dev/null @@ -1,127 +0,0 @@ -seed(PermissionTableSeeder::class); - $this->seed(DatabaseSeeder::class); - } - /** - * @test - */ - public function test_admin_anonymous_fetch() - { - - $this->response = $this->json( - 'GET', - '/api/admin/settings' - ); - $this->response->assertUnauthorized(); - - } - - public function test_admin_anonymous_fetch_paginate() - { - - $this->response = $this->json( - 'GET', - '/api/admin/settings?page=2' - ); - $this->response->assertUnauthorized(); - - } - - public function test_admin_anonymous_show() - { - - $setting = Setting::first(); - $this->response = $this->json( - 'GET', - '/api/admin/settings/' . $setting->id - ); - $this->response->assertUnauthorized(); - } - - public function test_admin_anonymous_groups() - { - - $setting = Setting::first(); - $this->response = $this->json( - 'GET', - '/api/admin/settings/groups' - ); - $this->response->assertUnauthorized(); - - } - - public function test_admin_anonymous_update() - { - $setting = Setting::first(); - - $input = [ - 'group' => 'config', - 'key' => 'app.env', - 'value' => "app.env", - 'public' => true, - 'enumerable' => true, - 'type' => 'config' - ]; - - $this->response = $this->json( - 'PUT', - '/api/admin/settings/'.$setting->id, - $input - ); - - $this->response->assertUnauthorized(); - - } - - public function test_admin_anonymous_create() - { - $input = [ - 'group' => 'config', - 'key' => 'app.env', - 'value' => "app.env", - 'public' => true, - 'enumerable' => true, - 'type' => 'config' - ]; - - $this->response = $this->json( - 'POST', - '/api/admin/settings', - $input - ); - - $this->response->assertUnauthorized(); - - } - - public function test_admin_anonymous_delete() - { - $setting = Setting::first(); - - $this->response = $this->json( - 'DELETE', - '/api/admin/settings/'.$setting->id, - ); - - $this->response->assertUnauthorized(); - - - } -} diff --git a/tests/API/SettingsAnonymousTest.php b/tests/API/SettingsAnonymousTest.php deleted file mode 100644 index 9ba19fc..0000000 --- a/tests/API/SettingsAnonymousTest.php +++ /dev/null @@ -1,95 +0,0 @@ - 'currencies', - 'key' => 'default', - 'value' => 'USD', - 'public' => true, - 'enumerable' => true, - 'type' => 'text' - ]); - - Setting::firstOrCreate([ - 'group' => 'currencies', - 'key' => 'enum', - 'value' => json_encode(["USD", "EUR"]), - 'public' => true, - 'enumerable' => true, - 'type' => 'json' - ]); - - Setting::firstOrCreate([ - 'group' => 'currencies', - 'key' => 'description', - 'value' => "Lorem Ipsum", - 'public' => true, - 'enumerable' => false, - 'type' => 'text' - ]); - - Setting::firstOrCreate([ - 'group' => 'currencies', - 'key' => 'hidden', - 'value' => "Lorem Ipsum", - 'public' => false, - 'enumerable' => false, - 'type' => 'text' - ]); - - Setting::firstOrCreate([ - 'group' => 'config', - 'key' => 'name', - 'value' => "app.name", - 'public' => true, - 'enumerable' => true, - 'type' => 'config' - ]); - } - /** - * @test - */ - public function test_anonymous_fetch() - { - - $this->response = $this->json( - 'GET', - '/api/settings' - ); - $this->response->assertOk(); - - $this->response->assertJsonFragment(['enum' => ["USD", "EUR"]]); - $this->response->assertJsonFragment(['name' => 'Lorem IPSUM']); - - // 'public' => false, - $this->response->assertJsonMissing(['hidden' => "Lorem Ipsum"]); - - // 'enumerable' => false, - $this->response->assertJsonMissing(['description' => "Lorem Ipsum"]); - } - - public function test_anonymous_show() - { - - $this->response = $this->json( - 'GET', - '/api/settings/currencies/description' - ); - $this->response->assertOk(); - - $this->response->assertJsonFragment(['value' => 'Lorem Ipsum']); - } -}