From ce6404471abd82d6e17d966c0bd0aec7146982bb Mon Sep 17 00:00:00 2001 From: Abner Tudtud Date: Thu, 13 Jul 2023 11:59:21 +0800 Subject: [PATCH] Add controller test --- .../Controllers/GraphQLControllerTest.php | 140 ++++++++++++++++++ .../Controllers/PlatformControllerTest.php | 2 +- 2 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 tests/Feature/Controllers/GraphQLControllerTest.php diff --git a/tests/Feature/Controllers/GraphQLControllerTest.php b/tests/Feature/Controllers/GraphQLControllerTest.php new file mode 100644 index 00000000..c4b02509 --- /dev/null +++ b/tests/Feature/Controllers/GraphQLControllerTest.php @@ -0,0 +1,140 @@ +json( + 'POST', + '/graphql', + ['query' => ' + query IntrospectionQuery { + __schema { + queryType + { + name + } + mutationType + { + name + } + types + { + ...FullType + } + directives + { + name + description + locations + args + { + ...InputValue + } + } + } + } + fragment FullType on __Type + { + kind + name + description + fields(includeDeprecated: true) + { + name + description + args + { + ...InputValue + } + type + { + ...TypeRef + } + isDeprecated + deprecationReason + } + inputFields + { + ...InputValue + } + interfaces + { + ...TypeRef + } + enumValues(includeDeprecated: true) + { + name + description + isDeprecated + deprecationReason + } + possibleTypes + { + ...TypeRef + } + } + fragment InputValue on __InputValue + { + name + description + type + { + ...TypeRef + } + defaultValue + } + fragment TypeRef on __Type + { + kind + name + ofType + { + kind + name + ofType + { + kind + name + ofType + { + kind + name + ofType + { + kind + name + ofType + { + kind + name + ofType + { + kind + name + ofType + { + kind + name + } + } + } + } + } + } + } + } + ', + ] + ); + + $this->assertTrue($response->isOk()); + } +} diff --git a/tests/Feature/Controllers/PlatformControllerTest.php b/tests/Feature/Controllers/PlatformControllerTest.php index cd04be12..e82a9113 100644 --- a/tests/Feature/Controllers/PlatformControllerTest.php +++ b/tests/Feature/Controllers/PlatformControllerTest.php @@ -10,7 +10,7 @@ class PlatformControllerTest extends TestCaseGraphQL public function test_it_can_get_platform_info(): void { $response = $this->json('GET', '/.well-known/enjin-platform.json'); - $this->assertTrue($response->getStatusCode() === 200); + $this->assertTrue($response->isOk()); $this->assertEquals( [ 'root' => 'enjin/platform-core',