From c14b84fcc08e4f99c98b001f08194b4239245fac Mon Sep 17 00:00:00 2001 From: Luciano Righetti Date: Fri, 7 Jan 2022 17:07:09 +0100 Subject: [PATCH] chg: rename test files --- .../TestCase/Api/Users/IndexUsersApiTest.php | 43 +++++++++++++++ tests/TestCase/Api/Users/ViewUserApiTest.php | 55 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 tests/TestCase/Api/Users/IndexUsersApiTest.php create mode 100644 tests/TestCase/Api/Users/ViewUserApiTest.php diff --git a/tests/TestCase/Api/Users/IndexUsersApiTest.php b/tests/TestCase/Api/Users/IndexUsersApiTest.php new file mode 100644 index 0000000..46e615d --- /dev/null +++ b/tests/TestCase/Api/Users/IndexUsersApiTest.php @@ -0,0 +1,43 @@ +initializeValidator(APP . '../webroot/docs/openapi.yaml'); + } + + public function testIndex(): void + { + $this->setAuthToken(AuthKeysFixture::ADMIN_API_KEY); + $this->get(self::ENDPOINT); + + $this->assertResponseOk(); + $this->assertResponseContains(sprintf('"username": "%s"', UsersFixture::USER_ADMIN_USERNAME)); + // TODO: $this->validateRequest() + $this->validateResponse(self::ENDPOINT); + } +} diff --git a/tests/TestCase/Api/Users/ViewUserApiTest.php b/tests/TestCase/Api/Users/ViewUserApiTest.php new file mode 100644 index 0000000..7c5a346 --- /dev/null +++ b/tests/TestCase/Api/Users/ViewUserApiTest.php @@ -0,0 +1,55 @@ +initializeValidator(APP . '../webroot/docs/openapi.yaml'); + } + + public function testViewMe(): void + { + $this->setAuthToken(AuthKeysFixture::ADMIN_API_KEY); + $this->get(self::ENDPOINT); + + $this->assertResponseOk(); + $this->assertResponseContains(sprintf('"username": "%s"', UsersFixture::USER_ADMIN_USERNAME)); + // TODO: $this->validateRequest() + $this->validateResponse(self::ENDPOINT); + } + + public function testViewById(): void + { + $this->setAuthToken(AuthKeysFixture::ADMIN_API_KEY); + $url = sprintf('%s/%d', self::ENDPOINT, UsersFixture::USER_ADMIN_ID); + $this->get($url); + + $this->assertResponseOk(); + $this->assertResponseContains(sprintf('"username": "%s"', UsersFixture::USER_ADMIN_USERNAME)); + // TODO: $this->validateRequest() + $this->validateResponse($url); + } +}