From 49a31a8f0eae100a20792bd1fa3d6a3e2864f7fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Pel=C3=AD=C5=A1ek?= Date: Tue, 28 Apr 2020 18:19:19 +0200 Subject: [PATCH] added some tests --- src/Resolver/Value/ValidatedValue.php | 2 +- tests/Spec/DirectiveTest.php | 4 +++ .../Type/Container/SimpleContainerTest.php | 28 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/Unit/Type/Container/SimpleContainerTest.php diff --git a/src/Resolver/Value/ValidatedValue.php b/src/Resolver/Value/ValidatedValue.php index b1a08d518..40c31dacd 100644 --- a/src/Resolver/Value/ValidatedValue.php +++ b/src/Resolver/Value/ValidatedValue.php @@ -47,6 +47,6 @@ public function jsonSerialize() public function printValue() : string { - return \json_encode($this->value, JSON_THROW_ON_ERROR, 512); + return \json_encode($this->value, \JSON_THROW_ON_ERROR); } } diff --git a/tests/Spec/DirectiveTest.php b/tests/Spec/DirectiveTest.php index 2d26e1f43..c41ef0a58 100644 --- a/tests/Spec/DirectiveTest.php +++ b/tests/Spec/DirectiveTest.php @@ -108,6 +108,10 @@ public function testRepeatable() : void public function invalidDataProvider() : array { return [ + [ + 'query queryName { field0 { field1 @skip(if: false) @skip(if: false) { name } } }', + \Graphpinator\Exception\Normalizer\DuplicatedDirective::class, + ], [ 'query queryName { field0 { field1 @include(if: false) @include(if: false) { name } } }', \Graphpinator\Exception\Normalizer\DuplicatedDirective::class, diff --git a/tests/Unit/Type/Container/SimpleContainerTest.php b/tests/Unit/Type/Container/SimpleContainerTest.php new file mode 100644 index 000000000..78061a814 --- /dev/null +++ b/tests/Unit/Type/Container/SimpleContainerTest.php @@ -0,0 +1,28 @@ +getTypes()); + self::assertCount(0, $container->getDirectives()); + + foreach ([ + 'ID', 'Int', 'Float', 'String', 'Boolean', + '__Schema', '__Type', '__TypeKind', '__Field', '__EnumValue', '__InputValue', + '__Directive', '__DirectiveLocation' + ] as $typeName) { + self::assertInstanceOf(\Graphpinator\Type\Contract\NamedDefinition::class, $container->getType($typeName)); + } + + foreach (['skip', 'include'] as $directiveName) { + self::assertInstanceOf(\Graphpinator\Directive\Directive::class, $container->getDirective($directiveName)); + } + } +}