Skip to content

Commit

Permalink
refactor(graphql)!: `GraphQLAssertions::assertCurrentGraphQLSchemaEqu…
Browse files Browse the repository at this point in the history
…als()` => `GraphQLAssertions::assertGraphQLSchemaEquals()`, `GraphQLAssertions::getCurrentGraphQLSchema()` => `GraphQLAssertions::getGraphQLSchema()`.
  • Loading branch information
LastDragon-ru committed Aug 15, 2023
1 parent 3b27a92 commit 1b0543e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions packages/graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,6 @@ $printed = $printer->print($schema);

There are also few great new [GraphQL Assertions](./src/Testing/GraphQLAssertions.php).

| Name | Description |
|------------------------------------|--------------------------|
| `assertCurrentGraphQLSchemaEquals` | Compares default schema. |
| Name | Description |
|-----------------------------|--------------------------|
| `assertGraphQLSchemaEquals` | Compares default schema. |
2 changes: 1 addition & 1 deletion packages/graphql/src/Builder/ManipulatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function getTypes(): TypeRegistry {
}
};

$schema = $this->useGraphQLSchema($graphql)->getCurrentGraphQLSchema();
$schema = $this->useGraphQLSchema($graphql)->getGraphQLSchema();
$query = $schema->getType('Query');
$field = $query instanceof ObjectType
? $query->getField('field')->astNode
Expand Down
10 changes: 5 additions & 5 deletions packages/graphql/src/Printer/PrinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function testPrint(
Closure $typeFactory = null,
): void {
$schema = $schemaFactory($this);
$schema = $this->useGraphQLSchema($schema)->getCurrentGraphQLSchema();
$schema = $this->useGraphQLSchema($schema)->getGraphQLSchema();
$printer = $this->app->make(Printer::class)->setSettings($settings);
$type = $typeFactory ? $typeFactory($this, $schema) : null;
$printable = $printableFactory($this, $schema);
Expand Down Expand Up @@ -92,7 +92,7 @@ public function testExport(
Closure $typeFactory = null,
): void {
$schema = $schemaFactory($this);
$schema = $this->useGraphQLSchema($schema)->getCurrentGraphQLSchema();
$schema = $this->useGraphQLSchema($schema)->getGraphQLSchema();
$printer = $this->app->make(Printer::class)->setSettings($settings);
$type = $typeFactory ? $typeFactory($this, $schema) : null;
$exportable = $exportableFactory($this, $schema);
Expand All @@ -116,7 +116,7 @@ public function testPrintSchema(
Closure $printableFactory,
): void {
$schema = $schemaFactory($this);
$schema = $this->useGraphQLSchema($schema)->getCurrentGraphQLSchema();
$schema = $this->useGraphQLSchema($schema)->getGraphQLSchema();
$printer = $this->app->make(Printer::class)->setSettings($settings)->setLevel($level);
$printable = $printableFactory($this, $schema);
$actual = $printer->printSchema($printable);
Expand All @@ -139,7 +139,7 @@ public function testPrintSchemaType(
Closure $typeFactory,
): void {
$schema = $schemaFactory($this);
$schema = $this->useGraphQLSchema($schema)->getCurrentGraphQLSchema();
$schema = $this->useGraphQLSchema($schema)->getGraphQLSchema();
$printer = $this->app->make(Printer::class)->setSettings($settings)->setLevel($level);
$type = $typeFactory($this, $schema);
$actual = $printer->printSchemaType($schema, $type);
Expand All @@ -162,7 +162,7 @@ public function testPrintType(
Closure $typeFactory,
): void {
$schema = $schemaFactory($this);
$schema = $this->useGraphQLSchema($schema)->getCurrentGraphQLSchema();
$schema = $this->useGraphQLSchema($schema)->getGraphQLSchema();
$printer = $this->app->make(Printer::class)->setSettings($settings)->setLevel($level);
$type = $typeFactory($this, $schema);
$actual = $printer->printType($type);
Expand Down
4 changes: 2 additions & 2 deletions packages/graphql/src/SearchBy/Directives/DirectiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function testManipulateArgDefinition(Closure $expected, string $graphql,
self::getTestData()->file($graphql),
);

self::assertCurrentGraphQLSchemaEquals(
self::assertGraphQLSchemaEquals(
$expected($this),
);
}
Expand Down Expand Up @@ -170,7 +170,7 @@ public function testManipulateArgDefinitionProgrammaticallyAddedType(): void {
self::getTestData()->file('~programmatically.graphql'),
);

self::assertCurrentGraphQLSchemaEquals(
self::assertGraphQLSchemaEquals(
self::getTestData()->file('~programmatically-expected.graphql'),
);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/graphql/src/SortBy/Directives/DirectiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function testManipulateArgDefinition(Closure $expected, string $graphql,
self::getTestData()->file($graphql),
);

self::assertCurrentGraphQLSchemaEquals(
self::assertGraphQLSchemaEquals(
$expected($this),
);
}
Expand Down Expand Up @@ -160,7 +160,7 @@ public function testManipulateArgDefinitionTypeRegistry(): void {
self::getTestData()->file('~registry.graphql'),
);

self::assertCurrentGraphQLSchemaEquals(
self::assertGraphQLSchemaEquals(
self::getTestData()->file('~registry-expected.graphql'),
);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql/src/Testing/GraphQLAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ trait GraphQLAssertions {
/**
* Compares GraphQL schema with current (application) schema.
*/
public function assertCurrentGraphQLSchemaEquals(
public function assertGraphQLSchemaEquals(
GraphQLExpected|SplFileInfo|string $expected,
string $message = '',
): void {
self::assertGraphQLPrintableEquals(
$expected,
$this->getCurrentGraphQLSchema(),
$this->getGraphQLSchema(),
$message,
);
}
Expand All @@ -62,7 +62,7 @@ protected function resetGraphQLSchema(): static {
return $this;
}

protected function getCurrentGraphQLSchema(): Schema {
protected function getGraphQLSchema(): Schema {
return $this->getGraphQLSchemaBuilder()->schema();
}

Expand Down

0 comments on commit 1b0543e

Please sign in to comment.