Skip to content

Commit

Permalink
Merge pull request #21 from aboks/php8
Browse files Browse the repository at this point in the history
Add PHP 8 support
  • Loading branch information
ivome authored Apr 24, 2021
2 parents b227c17 + 5396859 commit 7055fd4
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 52 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/composer.lock
/vendor/
/bin/
/build/
/build/
/.phpunit.result.cache
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- nightly
- hhvm
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0
- nightly

install:
- composer install --prefer-dist
- composer install --prefer-dist

script:
- mkdir -p build/logs
- ./bin/phpunit --coverage-clover build/logs/clover.xml tests/
- mkdir -p build/logs
- ./bin/phpunit --coverage-clover build/logs/clover.xml tests/

after_script:
- ./bin/coveralls -v
- ./bin/coveralls -v
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"API"
],
"require": {
"php": ">=5.4,<8.0-DEV",
"webonyx/graphql-php": ">=0.7.0"
"php": "^7.1 || ^8.0",
"webonyx/graphql-php": "^14.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"satooshi/php-coveralls": "~1.0"
},
"config": {
Expand Down
3 changes: 2 additions & 1 deletion tests/Connection/ArrayConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
namespace GraphQLRelay\Tests\Connection;

use GraphQLRelay\Connection\ArrayConnection;
use PHPUnit\Framework\TestCase;

class ArrayConnectionTest extends \PHPUnit_Framework_TestCase
class ArrayConnectionTest extends TestCase
{
protected $letters = ['A', 'B', 'C', 'D', 'E'];

Expand Down
21 changes: 8 additions & 13 deletions tests/Connection/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
namespace GraphQLRelay\Tests\Connection;

use GraphQL\GraphQL;
use GraphQL\Schema;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
use GraphQL\Type\Schema;
use GraphQLRelay\Connection\ArrayConnection;
use GraphQLRelay\Connection\Connection;
use PHPUnit\Framework\TestCase;

class ConnectionTest extends \PHPUnit_Framework_TestCase
class ConnectionTest extends TestCase
{
/**
* @var array
Expand Down Expand Up @@ -45,7 +46,7 @@ class ConnectionTest extends \PHPUnit_Framework_TestCase
*/
protected $schema;

public function setup()
public function setup(): void
{
$this->allUsers = [
[ 'name' => 'Dan', 'friends' => [1, 2, 3, 4] ],
Expand Down Expand Up @@ -251,24 +252,18 @@ public function testWorksWithBackwardConnectionArgs()
$this->assertValidQuery($query, $expected);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testEdgeTypeThrowsWithoutNodeType() {
$this->expectException(\InvalidArgumentException::class);
Connection::createEdgeType([]);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testConnectionTypeThrowsWithoutNodeType() {
$this->expectException(\InvalidArgumentException::class);
Connection::createConnectionType([]);
}

/**
* @expectedException \InvalidArgumentException
*/
public function testConnectionDefinitionThrowsWithoutNodeType() {
$this->expectException(\InvalidArgumentException::class);
Connection::connectionDefinitions([]);
}

Expand All @@ -277,7 +272,7 @@ public function testConnectionDefinitionThrowsWithoutNodeType() {
*/
protected function assertValidQuery($query, $expected)
{
$result = GraphQL::execute($this->schema, $query);
$result = GraphQL::executeQuery($this->schema, $query)->toArray();
$this->assertEquals(['data' => $expected], $result);
}
}
9 changes: 5 additions & 4 deletions tests/Connection/SeparateConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
namespace GraphQLRelay\Tests\Connection;

use GraphQL\GraphQL;
use GraphQL\Schema;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
use GraphQL\Type\Schema;
use GraphQLRelay\Connection\ArrayConnection;
use GraphQLRelay\Connection\Connection;
use PHPUnit\Framework\TestCase;

class SeparateConnectionTest extends \PHPUnit_Framework_TestCase
class SeparateConnectionTest extends TestCase
{
/**
* @var array
Expand Down Expand Up @@ -55,7 +56,7 @@ class SeparateConnectionTest extends \PHPUnit_Framework_TestCase
*/
protected $schema;

public function setup()
public function setup(): void
{
$this->allUsers = [
[ 'name' => 'Dan', 'friends' => [1, 2, 3, 4] ],
Expand Down Expand Up @@ -277,7 +278,7 @@ public function testWorksWithBackwardConnectionArgs()
*/
protected function assertValidQuery($query, $expected)
{
$result = GraphQL::execute($this->schema, $query);
$result = GraphQL::executeQuery($this->schema, $query)->toArray();
$this->assertEquals(['data' => $expected], $result);
}
}
13 changes: 7 additions & 6 deletions tests/Mutation/MutationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@


use GraphQL\GraphQL;
use GraphQL\Schema;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
use GraphQL\Type\Schema;
use GraphQLRelay\Connection\Connection;
use GraphQLRelay\Mutation\Mutation;
use PHPUnit\Framework\TestCase;

class MutationTest extends \PHPUnit_Framework_TestCase
class MutationTest extends TestCase
{
/**
* @var ObjectType
Expand Down Expand Up @@ -51,7 +52,7 @@ class MutationTest extends \PHPUnit_Framework_TestCase
*/
protected $schema;

public function setup()
public function setup(): void
{
$this->simpleMutation = Mutation::mutationWithClientMutationId([
'name' => 'SimpleMutation',
Expand Down Expand Up @@ -163,7 +164,7 @@ public function testRequiresAnArgument() {
}
}';

$result = GraphQL::execute($this->schema, $query);
$result = GraphQL::executeQuery($this->schema, $query)->toArray();

$this->assertEquals(count($result['errors']), 1);
$this->assertEquals($result['errors'][0]['message'], 'Field "simpleMutation" argument "input" of type "SimpleMutationInput!" is required but not provided.');
Expand Down Expand Up @@ -459,7 +460,7 @@ public function testContainsCorrectField()
]
];

$result = GraphQL::execute($this->schema, $query);
$result = GraphQL::executeQuery($this->schema, $query)->toArray();

$this->assertValidQuery($query, $expected);
}
Expand Down Expand Up @@ -559,6 +560,6 @@ public function testContainsCorrectDeprecationReasons() {
*/
protected function assertValidQuery($query, $expected)
{
$this->assertEquals(['data' => $expected], GraphQL::execute($this->schema, $query));
$this->assertEquals(['data' => $expected], GraphQL::executeQuery($this->schema, $query)->toArray());
}
}
7 changes: 4 additions & 3 deletions tests/Node/NodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@


use GraphQL\GraphQL;
use GraphQL\Schema;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\ResolveInfo;
use GraphQL\Type\Schema;
use GraphQL\Type\Definition\Type;
use GraphQLRelay\Node\Node;
use PHPUnit\Framework\TestCase;


class NodeTest extends \PHPUnit_Framework_TestCase {
class NodeTest extends TestCase {
/**
* Node definition, so that it is only created once
*
Expand Down Expand Up @@ -402,7 +403,7 @@ protected function getUserData() {
*/
private function assertValidQuery($query, $expected)
{
$result = GraphQL::execute($this->getSchema(), $query);
$result = GraphQL::executeQuery($this->getSchema(), $query)->toArray();

$this->assertEquals(['data' => $expected], $result);
}
Expand Down
7 changes: 4 additions & 3 deletions tests/Node/PluralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@


use GraphQL\GraphQL;
use GraphQL\Schema;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
use GraphQL\Type\Schema;
use GraphQLRelay\Node\Plural;
use PHPUnit\Framework\TestCase;

class PluralTest extends \PHPUnit_Framework_TestCase {
class PluralTest extends TestCase {
protected static function getSchema()
{
$userType = new ObjectType([
Expand Down Expand Up @@ -179,7 +180,7 @@ public function testCorrectlyIntrospects()
*/
private function assertValidQuery($query, $expected)
{
$result = GraphQL::execute($this->getSchema(), $query, ['lang' => 'en']);
$result = GraphQL::executeQuery($this->getSchema(), $query, ['lang' => 'en'])->toArray();
$this->assertEquals(['data' => $expected], $result);
}
}
3 changes: 2 additions & 1 deletion tests/RelayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
use GraphQL\Type\Definition\ObjectType;
use GraphQLRelay\Connection\Connection;
use GraphQLRelay\Relay;
use PHPUnit\Framework\TestCase;

class RelayTest extends \PHPUnit_Framework_TestCase
class RelayTest extends TestCase
{
public function testForwardConnectionArgs()
{
Expand Down
5 changes: 3 additions & 2 deletions tests/StarWarsConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@


use GraphQL\GraphQL;
use PHPUnit\Framework\TestCase;

class StarWarsConnectionTest extends \PHPUnit_Framework_TestCase
class StarWarsConnectionTest extends TestCase
{
public function testFetchesTheFirstShipOfTheRebels()
{
Expand Down Expand Up @@ -283,7 +284,7 @@ public function testIdentifiesTheEndOfTheList()
*/
private function assertValidQuery($query, $expected)
{
$result = GraphQL::execute(StarWarsSchema::getSchema(), $query);
$result = GraphQL::executeQuery(StarWarsSchema::getSchema(), $query)->toArray();

$this->assertEquals(['data' => $expected], $result);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/StarWarsMutationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@


use GraphQL\GraphQL;
use PHPUnit\Framework\TestCase;

class StarWarsMutationTest extends \PHPUnit_Framework_TestCase
class StarWarsMutationTest extends TestCase
{
public function testMutatesTheDataSet()
{
Expand Down Expand Up @@ -52,7 +53,7 @@ public function testMutatesTheDataSet()
),
);

$result = GraphQL::execute(StarWarsSchema::getSchema(), $mutation, null, null, $params);
$result = GraphQL::executeQuery(StarWarsSchema::getSchema(), $mutation, null, null, $params)->toArray();

$this->assertEquals(['data' => $expected], $result);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/StarWarsObjectIdentificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@


use GraphQL\GraphQL;
use PHPUnit\Framework\TestCase;

class StarWarsObjectIdentificationTest extends \PHPUnit_Framework_TestCase
class StarWarsObjectIdentificationTest extends TestCase
{
public function testFetchesTheIDAndNameOfTheRebels()
{
Expand Down Expand Up @@ -123,7 +124,7 @@ public function testRefetchesTheXWing()
*/
private function assertValidQuery($query, $expected)
{
$result = GraphQL::execute(StarWarsSchema::getSchema(), $query);
$result = GraphQL::executeQuery(StarWarsSchema::getSchema(), $query)->toArray();

$this->assertEquals(['data' => $expected], $result);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/StarWarsSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
namespace GraphQLRelay\tests;


use GraphQL\Schema;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
use GraphQL\Type\Schema;
use GraphQLRelay\Relay;

class StarWarsSchema {
Expand Down

0 comments on commit 7055fd4

Please sign in to comment.