-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(graphql): Added
assertGraphQLSchemaNoDangerousChanges()
assert…
…ion.
- Loading branch information
1 parent
ed9bfc1
commit ee41b8c
Showing
5 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
packages/graphql/docs/Assertions/AssertGraphQLSchemaNoDangerousChanges.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# `assertGraphQLSchemaNoDangerousChanges` | ||
|
||
Checks that no dangerous changes in the default internal schema (with all directives). | ||
|
||
[include:example]: ./AssertGraphQLSchemaNoDangerousChangesTest.php | ||
[//]: # (start: e89808347215c25407fece361d856f4087c43ac0599c7f65bba42fc4afc4fd51) | ||
[//]: # (warning: Generated automatically. Do not edit.) | ||
|
||
```php | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Assertions; | ||
|
||
use Illuminate\Container\Container; | ||
use LastDragon_ru\LaraASP\GraphQL\Provider; | ||
use LastDragon_ru\LaraASP\GraphQL\Testing\GraphQLAssertions; | ||
use LastDragon_ru\LaraASP\GraphQL\Testing\Package\Directives\TestDirective; | ||
use LastDragon_ru\LaraASP\GraphQL\Testing\Package\Provider as TestProvider; | ||
use LastDragon_ru\LaraASP\Testing\Package\TestCase; | ||
use Nuwave\Lighthouse\LighthouseServiceProvider; | ||
use Nuwave\Lighthouse\Schema\DirectiveLocator; | ||
use Override; | ||
use PHPUnit\Framework\Attributes\CoversNothing; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
#[CoversNothing] | ||
final class AssertGraphQLSchemaNoDangerousChangesTest extends TestCase { | ||
/** | ||
* Trait where assertion defined. | ||
*/ | ||
use GraphQLAssertions; | ||
|
||
/** | ||
* Preparation for test. | ||
* | ||
* @inheritDoc | ||
*/ | ||
#[Override] | ||
protected function getPackageProviders(mixed $app): array { | ||
return [ | ||
Provider::class, | ||
TestProvider::class, | ||
LighthouseServiceProvider::class, | ||
]; | ||
} | ||
|
||
/** | ||
* Assertion test. | ||
*/ | ||
public function testAssertion(): void { | ||
// Prepare | ||
Container::getInstance()->make(DirectiveLocator::class) | ||
->setResolved('test', TestDirective::class); | ||
|
||
$this->useGraphQLSchema( | ||
<<<'GRAPHQL' | ||
type Query { | ||
a(a: Int = 123): String @test | ||
} | ||
GRAPHQL, | ||
); | ||
|
||
// Test | ||
$this->assertGraphQLSchemaNoDangerousChanges( | ||
<<<'GRAPHQL' | ||
directive @test on FIELD_DEFINITION | ||
|
||
type Query { | ||
a(a: Int = 123): String @test | ||
} | ||
GRAPHQL, | ||
); | ||
} | ||
} | ||
``` | ||
|
||
[//]: # (end: e89808347215c25407fece361d856f4087c43ac0599c7f65bba42fc4afc4fd51) |
67 changes: 67 additions & 0 deletions
67
packages/graphql/docs/Assertions/AssertGraphQLSchemaNoDangerousChangesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Assertions; | ||
|
||
use Illuminate\Container\Container; | ||
use LastDragon_ru\LaraASP\GraphQL\Provider; | ||
use LastDragon_ru\LaraASP\GraphQL\Testing\GraphQLAssertions; | ||
use LastDragon_ru\LaraASP\GraphQL\Testing\Package\Directives\TestDirective; | ||
use LastDragon_ru\LaraASP\GraphQL\Testing\Package\Provider as TestProvider; | ||
use LastDragon_ru\LaraASP\Testing\Package\TestCase; | ||
use Nuwave\Lighthouse\LighthouseServiceProvider; | ||
use Nuwave\Lighthouse\Schema\DirectiveLocator; | ||
use Override; | ||
use PHPUnit\Framework\Attributes\CoversNothing; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
#[CoversNothing] | ||
final class AssertGraphQLSchemaNoDangerousChangesTest extends TestCase { | ||
/** | ||
* Trait where assertion defined. | ||
*/ | ||
use GraphQLAssertions; | ||
|
||
/** | ||
* Preparation for test. | ||
* | ||
* @inheritDoc | ||
*/ | ||
#[Override] | ||
protected function getPackageProviders(mixed $app): array { | ||
return [ | ||
Provider::class, | ||
TestProvider::class, | ||
LighthouseServiceProvider::class, | ||
]; | ||
} | ||
|
||
/** | ||
* Assertion test. | ||
*/ | ||
public function testAssertion(): void { | ||
// Prepare | ||
Container::getInstance()->make(DirectiveLocator::class) | ||
->setResolved('test', TestDirective::class); | ||
|
||
$this->useGraphQLSchema( | ||
<<<'GRAPHQL' | ||
type Query { | ||
a(a: Int = 123): String @test | ||
} | ||
GRAPHQL, | ||
); | ||
|
||
// Test | ||
$this->assertGraphQLSchemaNoDangerousChanges( | ||
<<<'GRAPHQL' | ||
directive @test on FIELD_DEFINITION | ||
type Query { | ||
a(a: Int = 123): String @test | ||
} | ||
GRAPHQL, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters