mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 12:56:05 +03:00
Merge pull request #332 from simPod/cs-tests-error
Fix CS in tests/Error
This commit is contained in:
commit
cf4cefc2bc
@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Tests\Error;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
@ -10,20 +13,20 @@ use PHPUnit\Framework\TestCase;
|
||||
class ErrorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @it uses the stack of an original error
|
||||
* @see it('uses the stack of an original error')
|
||||
*/
|
||||
public function testUsesTheStackOfAnOriginalError()
|
||||
public function testUsesTheStackOfAnOriginalError() : void
|
||||
{
|
||||
$prev = new \Exception("Original");
|
||||
$prev = new \Exception('Original');
|
||||
$err = new Error('msg', null, null, null, null, $prev);
|
||||
|
||||
$this->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('{
|
||||
field
|
||||
@ -39,9 +42,9 @@ 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('{
|
||||
field
|
||||
@ -57,9 +60,9 @@ 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('{
|
||||
field
|
||||
@ -75,9 +78,9 @@ 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
|
||||
@ -91,18 +94,18 @@ 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]);
|
||||
@ -114,9 +117,9 @@ 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',
|
||||
@ -131,9 +134,9 @@ class ErrorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @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([
|
||||
$this->assertEquals(
|
||||
[
|
||||
'message' => 'msg',
|
||||
'extensions' => ['foo' => 'bar'],
|
||||
], $e->toSerializableArray());
|
||||
],
|
||||
$e->toSerializableArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GraphQL\Tests\Error;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
@ -10,12 +13,10 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PrintErrorTest extends TestCase
|
||||
{
|
||||
// Describe printError
|
||||
|
||||
/**
|
||||
* @it prints an line numbers with correct padding
|
||||
* @see it('prints an line numbers with correct padding')
|
||||
*/
|
||||
public function testPrintsAnLineNumbersWithCorrectPadding()
|
||||
public function testPrintsAnLineNumbersWithCorrectPadding() : void
|
||||
{
|
||||
$singleDigit = new Error(
|
||||
'Single digit line number with no padding',
|
||||
@ -51,11 +52,12 @@ Test (9:1)
|
||||
}
|
||||
|
||||
/**
|
||||
* @it prints an error with nodes from different sources
|
||||
* @see it('prints an error with nodes from different sources')
|
||||
*/
|
||||
public function testPrintsAnErrorWithNodesFromDifferentSources()
|
||||
public function testPrintsAnErrorWithNodesFromDifferentSources() : void
|
||||
{
|
||||
$sourceA = Parser::parse(new Source('type Foo {
|
||||
$sourceA = Parser::parse(new Source(
|
||||
'type Foo {
|
||||
field: String
|
||||
}',
|
||||
'SourceA'
|
||||
@ -63,7 +65,8 @@ Test (9:1)
|
||||
|
||||
$fieldTypeA = $sourceA->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',
|
||||
[
|
||||
|
Loading…
Reference in New Issue
Block a user