From ee5a661e46d3993ce32c4b8b290ab046e0532cfe Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Fri, 5 Mar 2021 09:01:29 -0700 Subject: [PATCH] tests(integration): fixes EggControllerTest, NestControllerTest, and UserControllerTest --- .../{Nests => Eggs}/EggControllerTest.php | 18 ++++++------------ .../Application/Nests/NestControllerTest.php | 3 ++- .../Application/Users/UserControllerTest.php | 11 ++++++++--- 3 files changed, 16 insertions(+), 16 deletions(-) rename tests/Integration/Api/Application/{Nests => Eggs}/EggControllerTest.php (87%) diff --git a/tests/Integration/Api/Application/Nests/EggControllerTest.php b/tests/Integration/Api/Application/Eggs/EggControllerTest.php similarity index 87% rename from tests/Integration/Api/Application/Nests/EggControllerTest.php rename to tests/Integration/Api/Application/Eggs/EggControllerTest.php index 584a64521..a25549383 100644 --- a/tests/Integration/Api/Application/Nests/EggControllerTest.php +++ b/tests/Integration/Api/Application/Eggs/EggControllerTest.php @@ -1,6 +1,6 @@ repository->find(1); - $response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/' . $egg->id); + $response = $this->getJson('/api/application/eggs/' . $egg->id); $response->assertStatus(Response::HTTP_OK); $response->assertJsonStructure([ 'object', @@ -98,7 +95,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase { $egg = $this->repository->find(1); - $response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/' . $egg->id . '?include=servers,variables,nest'); + $response = $this->getJson('/api/application/eggs/' . $egg->id . '?include=servers,variables,nest'); $response->assertStatus(Response::HTTP_OK); $response->assertJsonStructure([ 'object', @@ -117,9 +114,7 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase */ public function testGetMissingEgg() { - $egg = $this->repository->find(1); - - $response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/nil'); + $response = $this->getJson('/api/application/nests/eggs/nil'); $this->assertNotFoundJson($response); } @@ -142,10 +137,9 @@ class EggControllerTest extends ApplicationApiIntegrationTestCase */ public function testResourceIsNotExposedWithoutPermissions() { - $egg = $this->repository->find(1); $this->createNewDefaultApiKey($this->getApiUser(), ['r_eggs' => 0]); - $response = $this->getJson('/api/application/nests/' . $egg->nest_id . '/eggs/nil'); + $response = $this->getJson('/api/application/nests/eggs/nil'); $this->assertAccessDeniedJson($response); } } diff --git a/tests/Integration/Api/Application/Nests/NestControllerTest.php b/tests/Integration/Api/Application/Nests/NestControllerTest.php index 58434ec4c..679e152b7 100644 --- a/tests/Integration/Api/Application/Nests/NestControllerTest.php +++ b/tests/Integration/Api/Application/Nests/NestControllerTest.php @@ -38,7 +38,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase $response->assertJsonStructure([ 'object', 'data' => [['object', 'attributes' => ['id', 'uuid', 'author', 'name', 'description', 'created_at', 'updated_at']]], - 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']], + 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages', 'links']], ]); $response->assertJson([ @@ -51,6 +51,7 @@ class NestControllerTest extends ApplicationApiIntegrationTestCase 'per_page' => 50, 'current_page' => 1, 'total_pages' => 1, + 'links' => [], ], ], ]); diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php index 00b091589..552c96380 100644 --- a/tests/Integration/Api/Application/Users/UserControllerTest.php +++ b/tests/Integration/Api/Application/Users/UserControllerTest.php @@ -24,10 +24,10 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $response->assertJsonStructure([ 'object', 'data' => [ - ['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at']], - ['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at']], + ['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'avatar_url', 'role_name', 'created_at', 'updated_at']], + ['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'avatar_url', 'role_name', 'created_at', 'updated_at']], ], - 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages']], + 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages', 'links']], ]); $response @@ -41,6 +41,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase 'per_page' => 100, 'current_page' => 1, 'total_pages' => 1, + 'links' => [], ], ], ]) @@ -57,6 +58,8 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase 'language' => $this->getApiUser()->language, 'root_admin' => (bool) $this->getApiUser()->root_admin, '2fa' => (bool) $this->getApiUser()->totp_enabled, + 'avatar_url' => $this->getApiUser()->avatarURL(), + 'role_name' => $this->getApiUser()->adminRoleName(), 'created_at' => $this->formatTimestamp($this->getApiUser()->created_at), 'updated_at' => $this->formatTimestamp($this->getApiUser()->updated_at), ], @@ -74,6 +77,8 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase 'language' => $user->language, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->totp_enabled, + 'avatar_url' => $user->getApiUser()->avatarURL(), + 'role_name' => $user->getApiUser()->adminRoleName(), 'created_at' => $this->formatTimestamp($user->created_at), 'updated_at' => $this->formatTimestamp($user->updated_at), ],