Skip to content

Commit

Permalink
Merge pull request #1167 from duncanmcclean/phpunit-attributes
Browse files Browse the repository at this point in the history
Adopt PHPUnit attributes
  • Loading branch information
mfn authored Feb 24, 2025
2 parents 8a9de2d + aacc582 commit 3e5091a
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 37 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ CHANGELOG
## Added
- Support for Laravel 12 [\#1164 / duncanmcclean](https://github.com/rebing/graphql-laravel/pull/1164)

## Changed
- Adopted PHPUnit attributes in the test suite [#1167 / duncanmcclean](https://github.com/rebing/graphql-laravel/pull/1167)

2024-11-22, 9.7.0
-----------------

Expand Down
3 changes: 2 additions & 1 deletion tests/Database/EmptyQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

use Laragraph\Utils\BadRequestGraphQLException;
use Orchestra\Testbench\Attributes\WithConfig;
use PHPUnit\Framework\Attributes\DataProvider;
use Rebing\GraphQL\Tests\TestCaseDatabase;

class EmptyQueryTest extends TestCaseDatabase
{
/**
* @dataProvider dataForEmptyQuery
* @param list<mixed> $parameters
*/
#[DataProvider('dataForEmptyQuery')]
public function testEmptyQuery(array $parameters, string $expectedError): void
{
$response = $this->call('GET', '/graphql', $parameters);
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Console/EnumMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\Console;

use PHPUnit\Framework\Attributes\DataProvider;
use Rebing\GraphQL\Console\EnumMakeCommand;
use Rebing\GraphQL\Tests\Support\Traits\MakeCommandAssertionTrait;
use Rebing\GraphQL\Tests\TestCase;
Expand All @@ -11,9 +12,7 @@ class EnumMakeCommandTest extends TestCase
{
use MakeCommandAssertionTrait;

/**
* @dataProvider dataForMakeCommand
*/
#[DataProvider('dataForMakeCommand')]
public function testCommand(
string $inputName,
string $expectedFilename,
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Console/ExecutionMiddlewareMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\Console;

use PHPUnit\Framework\Attributes\DataProvider;
use Rebing\GraphQL\Console\ExecutionMiddlewareMakeCommand;
use Rebing\GraphQL\Tests\Support\Traits\MakeCommandAssertionTrait;
use Rebing\GraphQL\Tests\TestCase;
Expand All @@ -11,9 +12,7 @@ class ExecutionMiddlewareMakeCommandTest extends TestCase
{
use MakeCommandAssertionTrait;

/**
* @dataProvider dataForMakeCommand
*/
#[DataProvider('dataForMakeCommand')]
public function testCommand(
string $inputName,
string $expectedFilename,
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Console/InputMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\Console;

use PHPUnit\Framework\Attributes\DataProvider;
use Rebing\GraphQL\Console\InputMakeCommand;
use Rebing\GraphQL\Tests\Support\Traits\MakeCommandAssertionTrait;
use Rebing\GraphQL\Tests\TestCase;
Expand All @@ -11,9 +12,7 @@ class InputMakeCommandTest extends TestCase
{
use MakeCommandAssertionTrait;

/**
* @dataProvider dataForMakeCommand
*/
#[DataProvider('dataForMakeCommand')]
public function testCommand(
string $inputName,
string $expectedFilename,
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Console/InterfaceMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\Console;

use PHPUnit\Framework\Attributes\DataProvider;
use Rebing\GraphQL\Console\InterfaceMakeCommand;
use Rebing\GraphQL\Tests\Support\Traits\MakeCommandAssertionTrait;
use Rebing\GraphQL\Tests\TestCase;
Expand All @@ -11,9 +12,7 @@ class InterfaceMakeCommandTest extends TestCase
{
use MakeCommandAssertionTrait;

/**
* @dataProvider dataForMakeCommand
*/
#[DataProvider('dataForMakeCommand')]
public function testCommand(
string $inputName,
string $expectedFilename,
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Console/MiddlewareMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\Console;

use PHPUnit\Framework\Attributes\DataProvider;
use Rebing\GraphQL\Console\MiddlewareMakeCommand;
use Rebing\GraphQL\Tests\Support\Traits\MakeCommandAssertionTrait;
use Rebing\GraphQL\Tests\TestCase;
Expand All @@ -11,9 +12,7 @@ class MiddlewareMakeCommandTest extends TestCase
{
use MakeCommandAssertionTrait;

/**
* @dataProvider dataForMakeCommand
*/
#[DataProvider('dataForMakeCommand')]
public function testCommand(
string $inputName,
string $expectedFilename,
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Console/MutationMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\Console;

use PHPUnit\Framework\Attributes\DataProvider;
use Rebing\GraphQL\Console\MutationMakeCommand;
use Rebing\GraphQL\Tests\Support\Traits\MakeCommandAssertionTrait;
use Rebing\GraphQL\Tests\TestCase;
Expand All @@ -11,9 +12,7 @@ class MutationMakeCommandTest extends TestCase
{
use MakeCommandAssertionTrait;

/**
* @dataProvider dataForMakeCommand
*/
#[DataProvider('dataForMakeCommand')]
public function testCommand(
string $inputName,
string $expectedFilename,
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Console/QueryMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\Console;

use PHPUnit\Framework\Attributes\DataProvider;
use Rebing\GraphQL\Console\QueryMakeCommand;
use Rebing\GraphQL\Tests\Support\Traits\MakeCommandAssertionTrait;
use Rebing\GraphQL\Tests\TestCase;
Expand All @@ -11,9 +12,7 @@ class QueryMakeCommandTest extends TestCase
{
use MakeCommandAssertionTrait;

/**
* @dataProvider dataForMakeCommand
*/
#[DataProvider('dataForMakeCommand')]
public function testCommand(
string $inputName,
string $expectedFilename,
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Console/ScalarMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\Console;

use PHPUnit\Framework\Attributes\DataProvider;
use Rebing\GraphQL\Console\ScalarMakeCommand;
use Rebing\GraphQL\Tests\Support\Traits\MakeCommandAssertionTrait;
use Rebing\GraphQL\Tests\TestCase;
Expand All @@ -11,9 +12,7 @@ class ScalarMakeCommandTest extends TestCase
{
use MakeCommandAssertionTrait;

/**
* @dataProvider dataForMakeCommand
*/
#[DataProvider('dataForMakeCommand')]
public function testCommand(
string $inputName,
string $expectedFilename,
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Console/SchemaConfigMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\Console;

use PHPUnit\Framework\Attributes\DataProvider;
use Rebing\GraphQL\Console\SchemaConfigMakeCommand;
use Rebing\GraphQL\Tests\Support\Traits\MakeCommandAssertionTrait;
use Rebing\GraphQL\Tests\TestCase;
Expand All @@ -11,9 +12,7 @@ class SchemaConfigMakeCommandTest extends TestCase
{
use MakeCommandAssertionTrait;

/**
* @dataProvider dataForMakeCommand
*/
#[DataProvider('dataForMakeCommand')]
public function testCommand(
string $inputName,
string $expectedFilename,
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Console/TypeMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\Console;

use PHPUnit\Framework\Attributes\DataProvider;
use Rebing\GraphQL\Console\TypeMakeCommand;
use Rebing\GraphQL\Tests\Support\Traits\MakeCommandAssertionTrait;
use Rebing\GraphQL\Tests\TestCase;
Expand All @@ -11,9 +12,7 @@ class TypeMakeCommandTest extends TestCase
{
use MakeCommandAssertionTrait;

/**
* @dataProvider dataForMakeCommand
*/
#[DataProvider('dataForMakeCommand')]
public function testCommand(
string $inputName,
string $expectedFilename,
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Console/UnionMakeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\Console;

use PHPUnit\Framework\Attributes\DataProvider;
use Rebing\GraphQL\Console\UnionMakeCommand;
use Rebing\GraphQL\Tests\Support\Traits\MakeCommandAssertionTrait;
use Rebing\GraphQL\Tests\TestCase;
Expand All @@ -11,9 +12,7 @@ class UnionMakeCommandTest extends TestCase
{
use MakeCommandAssertionTrait;

/**
* @dataProvider dataForMakeCommand
*/
#[DataProvider('dataForMakeCommand')]
public function testCommand(
string $inputName,
string $expectedFilename,
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/GraphQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use GraphQL\Type\Schema;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Traits\Macroable;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use Rebing\GraphQL\Error\ValidationError;
use Rebing\GraphQL\Exception\SchemaNotFound;
use Rebing\GraphQL\Exception\TypeNotFound;
Expand Down Expand Up @@ -45,9 +46,7 @@ public function testSchemaWithName(): void
self::assertArrayHasKey('Example', $schema->getTypeMap());
}

/**
* @doesNotPerformAssertions
*/
#[DoesNotPerformAssertions]
public function testSchemaIsValidWithInputFieldAliases(): void
{
$schema = GraphQL::buildSchemaFromConfig([
Expand Down

0 comments on commit 3e5091a

Please sign in to comment.