From 3170951620c650732f5c05bca982b40dcc10a9e3 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Tue, 28 Aug 2018 11:08:43 +0200 Subject: [PATCH] Fix CS in /tests/Error --- tests/Error/ErrorTest.php | 82 ++++++++++++++++++---------------- tests/Error/PrintErrorTest.php | 28 ++++++------ 2 files changed, 59 insertions(+), 51 deletions(-) diff --git a/tests/Error/ErrorTest.php b/tests/Error/ErrorTest.php index 03abbad..3ea9974 100644 --- a/tests/Error/ErrorTest.php +++ b/tests/Error/ErrorTest.php @@ -1,4 +1,7 @@ assertSame($err->getPrevious(), $prev); } /** - * @it converts nodes to positions and locations + * @see it('converts nodes to positions and locations') */ - public function testConvertsNodesToPositionsAndLocations() + public function testConvertsNodesToPositionsAndLocations() : void { - $source = new Source('{ + $source = new Source('{ field }'); - $ast = Parser::parse($source); + $ast = Parser::parse($source); $fieldNode = $ast->definitions[0]->selectionSet->selections[0]; - $e = new Error('msg', [ $fieldNode ]); + $e = new Error('msg', [$fieldNode]); $this->assertEquals([$fieldNode], $e->nodes); $this->assertEquals($source, $e->getSource()); @@ -39,16 +42,16 @@ class ErrorTest extends TestCase } /** - * @it converts single node to positions and locations + * @see it('converts single node to positions and locations') */ - public function testConvertSingleNodeToPositionsAndLocations() + public function testConvertSingleNodeToPositionsAndLocations() : void { - $source = new Source('{ + $source = new Source('{ field }'); - $ast = Parser::parse($source); + $ast = Parser::parse($source); $fieldNode = $ast->definitions[0]->selectionSet->selections[0]; - $e = new Error('msg', $fieldNode); // Non-array value. + $e = new Error('msg', $fieldNode); // Non-array value. $this->assertEquals([$fieldNode], $e->nodes); $this->assertEquals($source, $e->getSource()); @@ -57,16 +60,16 @@ class ErrorTest extends TestCase } /** - * @it converts node with loc.start === 0 to positions and locations + * @see it('converts node with loc.start === 0 to positions and locations') */ - public function testConvertsNodeWithStart0ToPositionsAndLocations() + public function testConvertsNodeWithStart0ToPositionsAndLocations() : void { - $source = new Source('{ + $source = new Source('{ field }'); - $ast = Parser::parse($source); + $ast = Parser::parse($source); $operationNode = $ast->definitions[0]; - $e = new Error('msg', [ $operationNode ]); + $e = new Error('msg', [$operationNode]); $this->assertEquals([$operationNode], $e->nodes); $this->assertEquals($source, $e->getSource()); @@ -75,14 +78,14 @@ class ErrorTest extends TestCase } /** - * @it converts source and positions to locations + * @see it('converts source and positions to locations') */ - public function testConvertsSourceAndPositionsToLocations() + public function testConvertsSourceAndPositionsToLocations() : void { $source = new Source('{ field }'); - $e = new Error('msg', null, $source, [ 10 ]); + $e = new Error('msg', null, $source, [10]); $this->assertEquals(null, $e->nodes); $this->assertEquals($source, $e->getSource()); @@ -91,21 +94,21 @@ class ErrorTest extends TestCase } /** - * @it serializes to include message + * @see it('serializes to include message') */ - public function testSerializesToIncludeMessage() + public function testSerializesToIncludeMessage() : void { $e = new Error('msg'); $this->assertEquals(['message' => 'msg'], $e->toSerializableArray()); } /** - * @it serializes to include message and locations + * @see it('serializes to include message and locations') */ - public function testSerializesToIncludeMessageAndLocations() + public function testSerializesToIncludeMessageAndLocations() : void { $node = Parser::parse('{ field }')->definitions[0]->selectionSet->selections[0]; - $e = new Error('msg', [ $node ]); + $e = new Error('msg', [$node]); $this->assertEquals( ['message' => 'msg', 'locations' => [['line' => 1, 'column' => 3]]], @@ -114,26 +117,26 @@ class ErrorTest extends TestCase } /** - * @it serializes to include path + * @see it('serializes to include path') */ - public function testSerializesToIncludePath() + public function testSerializesToIncludePath() : void { $e = new Error( 'msg', null, null, null, - [ 'path', 3, 'to', 'field' ] + ['path', 3, 'to', 'field'] ); - $this->assertEquals([ 'path', 3, 'to', 'field' ], $e->path); - $this->assertEquals(['message' => 'msg', 'path' => [ 'path', 3, 'to', 'field' ]], $e->toSerializableArray()); + $this->assertEquals(['path', 3, 'to', 'field'], $e->path); + $this->assertEquals(['message' => 'msg', 'path' => ['path', 3, 'to', 'field']], $e->toSerializableArray()); } /** - * @it default error formatter includes extension fields + * @see it('default error formatter includes extension fields') */ - public function testDefaultErrorFormatterIncludesExtensionFields() + public function testDefaultErrorFormatterIncludesExtensionFields() : void { $e = new Error( 'msg', @@ -146,9 +149,12 @@ class ErrorTest extends TestCase ); $this->assertEquals(['foo' => 'bar'], $e->getExtensions()); - $this->assertEquals([ - 'message' => 'msg', - 'extensions' => ['foo' => 'bar'], - ], $e->toSerializableArray()); + $this->assertEquals( + [ + 'message' => 'msg', + 'extensions' => ['foo' => 'bar'], + ], + $e->toSerializableArray() + ); } } diff --git a/tests/Error/PrintErrorTest.php b/tests/Error/PrintErrorTest.php index 8cff56c..86c9c55 100644 --- a/tests/Error/PrintErrorTest.php +++ b/tests/Error/PrintErrorTest.php @@ -1,4 +1,7 @@ definitions[0]->fields[0]->type; - $sourceB = Parser::parse(new Source('type Foo { + $sourceB = Parser::parse(new Source( + 'type Foo { field: Int }', 'SourceB' @@ -71,7 +74,6 @@ Test (9:1) $fieldTypeB = $sourceB->definitions[0]->fields[0]->type; - $error = new Error( 'Example error with two nodes', [