Skip to content

Commit 7acd176

Browse files
devmaslovmoufmouf
authored andcommitted
Adjusted unit tests for webonyx/graphql v14.6+
1 parent 7f98776 commit 7acd176

9 files changed

+52
-86
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"thecodingmachine/cache-utils": "^1",
2828
"thecodingmachine/class-explorer": "^1.1.0",
2929
"webmozart/assert": "^1.10",
30-
"webonyx/graphql-php": "^v14.5.0"
30+
"webonyx/graphql-php": "^14.6.1"
3131
},
3232
"require-dev": {
3333
"beberlei/porpaginas": "^1.2",

tests/Exceptions/ErrorHandlerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ErrorHandlerTest extends TestCase
1111
public function testErrorFormatter()
1212
{
1313
$exception = new GraphQLException('foo', 0, null, 'MyCategory', ['field' => 'foo']);
14-
$error = new Error('foo', null, null, null, null, $exception);
14+
$error = new Error('foo', null, null, [], null, $exception);
1515
$formattedError = WebonyxErrorHandler::errorFormatter($error);
1616

1717
$this->assertSame([
@@ -26,11 +26,11 @@ public function testErrorFormatter()
2626
public function testErrorHandler()
2727
{
2828
$exception = new GraphQLException('foo', 0, null, 'MyCategory', ['field' => 'foo']);
29-
$error = new Error('bar', null, null, null, null, $exception);
29+
$error = new Error('bar', null, null, [], null, $exception);
3030
$aggregateException = new GraphQLAggregateException();
3131
$aggregateException->add($exception);
3232
$aggregateException->add($exception);
33-
$aggregateError = new Error('bar', null, null, null, null, $aggregateException);
33+
$aggregateError = new Error('bar', null, null, [], null, $aggregateException);
3434
$formattedError = WebonyxErrorHandler::errorHandler([$error, $aggregateError], [WebonyxErrorHandler::class, 'errorFormatter']);
3535

3636
$this->assertSame([

tests/FieldsBuilderTest.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace TheCodingMachine\GraphQLite;
44

5-
use Doctrine\Common\Annotations\AnnotationReader;
6-
use GraphQL\Deferred;
75
use GraphQL\Type\Definition\BooleanType;
86
use GraphQL\Type\Definition\EnumType;
97
use GraphQL\Type\Definition\FloatType;
@@ -20,7 +18,6 @@
2018
use stdClass;
2119
use Symfony\Component\Cache\Adapter\ArrayAdapter;
2220
use Symfony\Component\Cache\Psr16Cache;
23-
use Symfony\Component\Cache\Simple\ArrayCache;
2421
use TheCodingMachine\GraphQLite\Annotations\Exceptions\InvalidParameterException;
2522
use TheCodingMachine\GraphQLite\Fixtures\TestController;
2623
use TheCodingMachine\GraphQLite\Fixtures\TestControllerNoReturnType;
@@ -30,22 +27,18 @@
3027
use TheCodingMachine\GraphQLite\Fixtures\TestControllerWithInvalidParameterAnnotation;
3128
use TheCodingMachine\GraphQLite\Fixtures\TestControllerWithParamDateTime;
3229
use TheCodingMachine\GraphQLite\Fixtures\TestControllerWithFailWith;
33-
use TheCodingMachine\GraphQLite\Fixtures\TestControllerWithInputType;
3430
use TheCodingMachine\GraphQLite\Fixtures\TestControllerWithInvalidInputType;
3531
use TheCodingMachine\GraphQLite\Fixtures\TestControllerWithNullableArray;
36-
use TheCodingMachine\GraphQLite\Fixtures\TestControllerWithParamIterator;
3732
use TheCodingMachine\GraphQLite\Fixtures\TestControllerWithReturnDateTime;
3833
use TheCodingMachine\GraphQLite\Fixtures\TestControllerWithUnionInputParam;
3934
use TheCodingMachine\GraphQLite\Fixtures\TestEnum;
4035
use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithInvalidPrefetchMethod;
4136
use TheCodingMachine\GraphQLite\Fixtures\TestControllerWithInvalidReturnType;
42-
use TheCodingMachine\GraphQLite\Fixtures\TestControllerWithIterableParam;
4337
use TheCodingMachine\GraphQLite\Fixtures\TestControllerWithIterableReturnType;
4438
use TheCodingMachine\GraphQLite\Fixtures\TestDoubleReturnTag;
4539
use TheCodingMachine\GraphQLite\Fixtures\TestFieldBadInputType;
4640
use TheCodingMachine\GraphQLite\Fixtures\TestFieldBadOutputType;
4741
use TheCodingMachine\GraphQLite\Fixtures\TestObject;
48-
use TheCodingMachine\GraphQLite\Fixtures\TestResolveInfo;
4942
use TheCodingMachine\GraphQLite\Fixtures\TestSelfType;
5043
use TheCodingMachine\GraphQLite\Fixtures\TestSourceFieldBadOutputType;
5144
use TheCodingMachine\GraphQLite\Fixtures\TestSourceFieldBadOutputType2;
@@ -59,14 +52,9 @@
5952
use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithMagicProperty;
6053
use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithPrefetchMethod;
6154
use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithSourceFieldInterface;
62-
use TheCodingMachine\GraphQLite\Containers\EmptyContainer;
63-
use TheCodingMachine\GraphQLite\Containers\BasicAutoWiringContainer;
6455
use TheCodingMachine\GraphQLite\Fixtures\TestTypeWithSourceFieldInvalidParameterAnnotation;
6556
use TheCodingMachine\GraphQLite\Mappers\CannotMapTypeException;
6657
use TheCodingMachine\GraphQLite\Mappers\CannotMapTypeExceptionInterface;
67-
use TheCodingMachine\GraphQLite\Mappers\Parameters\ResolveInfoParameterHandler;
68-
use TheCodingMachine\GraphQLite\Mappers\Root\BaseTypeMapper;
69-
use TheCodingMachine\GraphQLite\Mappers\Root\CompositeRootTypeMapper;
7058
use TheCodingMachine\GraphQLite\Middlewares\AuthorizationFieldMiddleware;
7159
use TheCodingMachine\GraphQLite\Middlewares\BadExpressionInSecurityException;
7260
use TheCodingMachine\GraphQLite\Middlewares\MissingMagicGetException;
@@ -78,7 +66,6 @@
7866
use TheCodingMachine\GraphQLite\Security\VoidAuthorizationService;
7967
use TheCodingMachine\GraphQLite\Annotations\Query;
8068
use TheCodingMachine\GraphQLite\Types\DateTimeType;
81-
use function var_dump;
8269

8370
class FieldsBuilderTest extends AbstractQueryProviderTest
8471
{
@@ -718,9 +705,9 @@ public function testQueryProviderWithNullableArray(): void
718705
$this->assertInstanceOf(NonNull::class, $usersQuery->args[0]->getType());
719706
$this->assertInstanceOf(ListOfType::class, $usersQuery->args[0]->getType()->getWrappedType());
720707
$this->assertInstanceOf(IntType::class, $usersQuery->args[0]->getType()->getWrappedType()->getWrappedType());
721-
$this->assertInstanceOf(NonNull::class, $usersQuery->type);
722-
$this->assertInstanceOf(ListOfType::class, $usersQuery->type->getWrappedType());
723-
$this->assertInstanceOf(IntType::class, $usersQuery->type->getWrappedType()->getWrappedType());
708+
$this->assertInstanceOf(NonNull::class, $usersQuery->getType());
709+
$this->assertInstanceOf(ListOfType::class, $usersQuery->getType()->getWrappedType());
710+
$this->assertInstanceOf(IntType::class, $usersQuery->getType()->getWrappedType()->getWrappedType());
724711
}
725712

726713
public function testQueryProviderWithParamDateTime(): void

tests/Http/HttpCodeDeciderTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ public function testDecideHttpStatusCode(): void
2222
$graphqlError = new Error('Foo');
2323

2424
$exception = new Exception('foo', 0);
25-
$errorCode0 = new Error('Foo', null, null, null, null, $exception);
25+
$errorCode0 = new Error('Foo', null, null, [], null, $exception);
2626

2727
$exception401 = new Exception('foo', 401);
28-
$errorCode401 = new Error('Foo', null, null, null, null, $exception401);
28+
$errorCode401 = new Error('Foo', null, null, [], null, $exception401);
2929

3030
$exception404 = new Exception('foo', 404);
31-
$errorCode404 = new Error('Foo', null, null, null, null, $exception404);
31+
$errorCode404 = new Error('Foo', null, null, [], null, $exception404);
3232

3333
$exception600 = new Exception('foo', 600);
34-
$errorCode600 = new Error('Foo', null, null, null, null, $exception600);
34+
$errorCode600 = new Error('Foo', null, null, [], null, $exception600);
3535

3636
$clientAwareException = new class extends Exception implements ClientAware {
3737
public function isClientSafe()
@@ -44,7 +44,7 @@ public function getCategory()
4444
return 'foo';
4545
}
4646
};
47-
$clientAwareError = new Error('Foo', null, null, null, null, $clientAwareException);
47+
$clientAwareError = new Error('Foo', null, null, [], null, $clientAwareException);
4848

4949
$executionResult = new ExecutionResult(null, [ $errorCode0 ]);
5050
$this->assertSame(500, $codeDecider->decideHttpStatusCode($executionResult));

tests/Http/WebonyxGraphqlMiddlewareTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
use GraphQL\Server\ServerConfig;
1010
use GraphQL\Server\StandardServer;
1111
use PHPUnit\Framework\TestCase;
12+
use Psr\Http\Message\RequestInterface;
1213
use Psr\Http\Message\ResponseInterface;
1314
use Psr\Http\Message\ServerRequestInterface;
14-
use Psr\Http\Message\StreamInterface;
1515
use Psr\Http\Server\RequestHandlerInterface;
1616
use RuntimeException;
17-
use Laminas\Diactoros\Response;
1817
use Laminas\Diactoros\Response\TextResponse;
1918
use Laminas\Diactoros\ResponseFactory;
2019
use Laminas\Diactoros\ServerRequest;
@@ -53,7 +52,7 @@ public function setExecutionResult($executionResult) : void
5352
/**
5453
* @return ExecutionResult|ExecutionResult[]|Promise
5554
*/
56-
public function executePsrRequest(ServerRequestInterface $request)
55+
public function executePsrRequest( RequestInterface $request)
5756
{
5857
return $this->executionResult;
5958
}

tests/Integration/AnnotatedInterfaceTest.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,11 @@
22

33
namespace TheCodingMachine\GraphQLite\Integration;
44

5-
use Doctrine\Common\Annotations\AnnotationReader as DoctrineAnnotationReader;
6-
use GraphQL\Error\Debug;
5+
use GraphQL\Error\DebugFlag;
76
use GraphQL\GraphQL;
8-
use GraphQL\Type\Definition\NonNull;
9-
use Mouf\Picotainer\Picotainer;
107
use PHPUnit\Framework\TestCase;
11-
use Psr\Container\ContainerInterface;
12-
use stdClass;
138
use Symfony\Component\Cache\Adapter\ArrayAdapter;
149
use Symfony\Component\Cache\Psr16Cache;
15-
use Symfony\Component\Cache\Simple\ArrayCache;
16-
use Symfony\Component\Lock\Factory as LockFactory;
17-
use Symfony\Component\Lock\Store\FlockStore;
18-
use Symfony\Component\Lock\Store\SemaphoreStore;
1910
use TheCodingMachine\GraphQLite\Containers\BasicAutoWiringContainer;
2011
use TheCodingMachine\GraphQLite\Containers\EmptyContainer;
2112
use TheCodingMachine\GraphQLite\Schema;
@@ -68,7 +59,7 @@ classA {
6859
'grandFather' => 'grandFather',
6960
'grandMother' => 'grandMother',
7061
]
71-
], $result->toArray(Debug::RETHROW_INTERNAL_EXCEPTIONS)['data'] ?? $result->toArray(Debug::RETHROW_INTERNAL_EXCEPTIONS)['errors']);
62+
], $result->toArray(DebugFlag::RETHROW_INTERNAL_EXCEPTIONS)['data'] ?? $result->toArray(DebugFlag::RETHROW_INTERNAL_EXCEPTIONS)['errors']);
7263
}
7364

7465
public function testAnnotatedInterfaceWithNotAnnotatedClass(): void
@@ -90,7 +81,7 @@ public function testAnnotatedInterfaceWithNotAnnotatedClass(): void
9081
'qux' => [
9182
'qux' => 'qux',
9283
]
93-
], $result->toArray(Debug::RETHROW_INTERNAL_EXCEPTIONS)['data'] ?? $result->toArray(Debug::RETHROW_INTERNAL_EXCEPTIONS)['errors']);
84+
], $result->toArray(DebugFlag::RETHROW_INTERNAL_EXCEPTIONS)['data'] ?? $result->toArray(DebugFlag::RETHROW_INTERNAL_EXCEPTIONS)['errors']);
9485
}
9586

9687
public function testAnnotatedInterfaceWithAnnotatedClass(): void
@@ -122,7 +113,7 @@ classD
122113
'parentValue' => 'parent',
123114
'classD' => 'classD',
124115
]
125-
], $result->toArray(Debug::RETHROW_INTERNAL_EXCEPTIONS)['data'] ?? $result->toArray(Debug::RETHROW_INTERNAL_EXCEPTIONS)['errors']);
116+
], $result->toArray(DebugFlag::RETHROW_INTERNAL_EXCEPTIONS)['data'] ?? $result->toArray(DebugFlag::RETHROW_INTERNAL_EXCEPTIONS)['errors']);
126117
}
127118

128119
}

0 commit comments

Comments
 (0)