Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- fixes bug in CompilerPass #182

Merged
merged 2 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion DependencyInjection/GraphQLiteCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,10 @@ private static function getParametersByName(ReflectionMethod $method): array
private function getAnnotationReader(): AnnotationReader
{
if ($this->annotationReader === null) {
AnnotationRegistry::registerLoader('class_exists');
// @phpstan-ignore-next-line "registerLoader exists in doctrine/annotations:v1.x"
if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
AnnotationRegistry::registerLoader('class_exists');
}

$doctrineAnnotationReader = new DoctrineAnnotationReader();

Expand Down
56 changes: 46 additions & 10 deletions Tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function testInjectQuery(): void
], $result);
}

public function testLoginQuery(): void
public function testLoginQueryWithRequestParams(): void
{
$kernel = new GraphQLiteTestingKernel();
$kernel->boot();
Expand All @@ -247,7 +247,43 @@ public function testLoginQuery(): void
}
'];

$request = Request::create('/graphql', 'POST', $parameters, [], [], ['CONTENT_TYPE' => 'application/json']);
$request = Request::create('/graphql', 'POST', $parameters);

$response = $kernel->handle($request);

$result = json_decode($response->getContent(), true);

$this->assertSame([
'data' => [
'login' => [
'userName' => 'foo',
'roles' => [
'ROLE_USER'
]
]
]
], $result);
}

public function testLoginQueryWithRequestBody(): void
{
$kernel = new GraphQLiteTestingKernel();
$kernel->boot();

$session = new Session(new MockArraySessionStorage());
$container = $kernel->getContainer();
$container->set('session', $session);

$body = ['query' => '
mutation login {
login(userName: "foo", password: "bar") {
userName
roles
}
}
'];

$request = Request::create('/graphql', 'POST', [], [], [], ['CONTENT_TYPE' => 'application/json'], json_encode($body));

$response = $kernel->handle($request);

Expand Down Expand Up @@ -283,7 +319,7 @@ public function testMeQuery(): void
}
'];

$request = Request::create('/graphql', 'POST', $parameters, [], [], ['CONTENT_TYPE' => 'application/json']);
$request = Request::create('/graphql', 'POST', $parameters);

$response = $kernel->handle($request);

Expand All @@ -310,7 +346,7 @@ public function testNoLoginNoSessionQuery(): void
}
'];

$request = Request::create('/graphql', 'POST', $parameters, [], [], ['CONTENT_TYPE' => 'application/json']);
$request = Request::create('/graphql', 'POST', $parameters);

$response = $kernel->handle($request);

Expand Down Expand Up @@ -394,7 +430,7 @@ public function testAllOff(): void
}
'];

$request = Request::create('/graphql', 'POST', $parameters, [], [], ['CONTENT_TYPE' => 'application/json']);
$request = Request::create('/graphql', 'POST', $parameters);

$response = $kernel->handle($request);

Expand All @@ -418,7 +454,7 @@ public function testValidation(): void
}
'];

$request = Request::create('/graphql', 'POST', $parameters, [], [], ['CONTENT_TYPE' => 'application/json']);
$request = Request::create('/graphql', 'POST', $parameters);

$response = $kernel->handle($request);

Expand All @@ -445,7 +481,7 @@ public function testWithIntrospection(): void
}
'];

$request = Request::create('/graphql', 'POST', $parameters, [], [], ['CONTENT_TYPE' => 'application/json']);
$request = Request::create('/graphql', 'POST', $parameters);

$response = $kernel->handle($request);

Expand All @@ -470,7 +506,7 @@ public function testDisableIntrospection(): void
}
'];

$request = Request::create('/graphql', 'POST', $parameters, [], [], ['CONTENT_TYPE' => 'application/json']);
$request = Request::create('/graphql', 'POST', $parameters);

$response = $kernel->handle($request);

Expand Down Expand Up @@ -498,7 +534,7 @@ public function testMaxQueryComplexity(): void
}
'];

$request = Request::create('/graphql', 'POST', $parameters, [], [], ['CONTENT_TYPE' => 'application/json']);
$request = Request::create('/graphql', 'POST', $parameters);

$response = $kernel->handle($request);

Expand Down Expand Up @@ -532,7 +568,7 @@ public function testMaxQueryDepth(): void
}
'];

$request = Request::create('/graphql', 'POST', $parameters, [], [], ['CONTENT_TYPE' => 'application/json']);
$request = Request::create('/graphql', 'POST', $parameters);

$response = $kernel->handle($request);

Expand Down
Loading