From 81d15f1ba864449f05de977896f31c1507ecbaf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Pel=C3=AD=C5=A1ek?= Date: Sun, 19 Apr 2020 17:32:09 +0200 Subject: [PATCH] isOutputable protected, added tests to match required mutation score --- src/Exception/GraphpinatorBase.php | 10 +++++----- src/Exception/Parser/ParserError.php | 2 +- src/Exception/Tokenizer/TokenizerError.php | 2 +- tests/Spec/ErrorsTest.php | 4 ++++ tests/Spec/TestSchema.php | 3 +++ 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Exception/GraphpinatorBase.php b/src/Exception/GraphpinatorBase.php index e1e4fab82..3e080baf0 100644 --- a/src/Exception/GraphpinatorBase.php +++ b/src/Exception/GraphpinatorBase.php @@ -21,11 +21,6 @@ public function __construct(?\Graphpinator\Source\Location $location = null, ?Pa $this->extensions = $extensions; } - public function isOutputable() : bool - { - return false; - } - final public function jsonSerialize() : array { if (!$this->isOutputable()) { @@ -57,4 +52,9 @@ public static function notOutputableResponse() : array 'message' => 'Server responded with unknown error.' ]; } + + protected function isOutputable() : bool + { + return false; + } } diff --git a/src/Exception/Parser/ParserError.php b/src/Exception/Parser/ParserError.php index 86a21ae6f..24090b0d3 100644 --- a/src/Exception/Parser/ParserError.php +++ b/src/Exception/Parser/ParserError.php @@ -6,7 +6,7 @@ abstract class ParserError extends \Graphpinator\Exception\GraphpinatorBase { - public function isOutputable() : bool + protected function isOutputable() : bool { return true; } diff --git a/src/Exception/Tokenizer/TokenizerError.php b/src/Exception/Tokenizer/TokenizerError.php index 0ee617a25..8c5c8defe 100644 --- a/src/Exception/Tokenizer/TokenizerError.php +++ b/src/Exception/Tokenizer/TokenizerError.php @@ -6,7 +6,7 @@ abstract class TokenizerError extends \Graphpinator\Exception\GraphpinatorBase { - public function isOutputable() : bool + protected function isOutputable() : bool { return true; } diff --git a/tests/Spec/ErrorsTest.php b/tests/Spec/ErrorsTest.php index 158953f0b..27e8fe86c 100644 --- a/tests/Spec/ErrorsTest.php +++ b/tests/Spec/ErrorsTest.php @@ -24,6 +24,10 @@ public function simpleDataProvider() : array 'query queryName { field0 @invalidDirective() { field1 { name } } }', \Infinityloop\Utils\Json::fromArray(['errors' => [['message' => 'Server responded with unknown error.']]]), ], + [ + 'query queryName { fieldThrow { field1 { name } } }', + \Infinityloop\Utils\Json::fromArray(['errors' => [['message' => 'Server responded with unknown error.']]]), + ], ]; } diff --git a/tests/Spec/TestSchema.php b/tests/Spec/TestSchema.php index 08a9987f5..cd29b5681 100644 --- a/tests/Spec/TestSchema.php +++ b/tests/Spec/TestSchema.php @@ -79,6 +79,9 @@ protected function getFieldDefinition() : \Graphpinator\Field\ResolvableFieldSet }), new \Graphpinator\Field\ResolvableField('fieldAbstract', TestSchema::getUnion(), static function () { return 1; + }), + new \Graphpinator\Field\ResolvableField('fieldThrow', TestSchema::getUnion(), static function () { + throw new \Exception('Random exception'); }) ]); }