From 27327f6553806c343c7d4c8e7f15aa25b67cd7f0 Mon Sep 17 00:00:00 2001 From: Ankit Pathak Date: Fri, 2 Aug 2024 17:26:25 +0530 Subject: [PATCH] Reverting changes for alterableSchemaTest. --- .../Entity/Fields/Image/ImageDerivative.php | 6 +++--- tests/src/Kernel/AlterableSchemaTest.php | 13 +++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php b/src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php index 0454a69cc..1df82d3a4 100644 --- a/src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php +++ b/src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php @@ -97,12 +97,12 @@ public function resolve(FileInterface $entity = NULL, $style, RefinableCacheable $access = $entity->access('view', NULL, TRUE); $metadata->addCacheableDependency($access); if ($access->isAllowed() && $image_style = ImageStyle::load($style)) { - + // @phpstan-ignore-next-line $width = $entity->width; + // @phpstan-ignore-next-line $height = $entity->height; - // @phpstan-ignore-next-line - if (empty($width) || empty($height)) { + if ($width == NULL || $height == NULL) { /** @var \Drupal\Core\Image\ImageInterface $image */ $image = \Drupal::service('image.factory')->get($entity->getFileUri()); if ($image->isValid()) { diff --git a/tests/src/Kernel/AlterableSchemaTest.php b/tests/src/Kernel/AlterableSchemaTest.php index c77c4aaa5..961e46645 100644 --- a/tests/src/Kernel/AlterableSchemaTest.php +++ b/tests/src/Kernel/AlterableSchemaTest.php @@ -114,9 +114,9 @@ public function testEmptySchemaExtensionAlteredQueryResultPropertyAdded(): void $this->assertSame([ 'errors' => [ 0 => [ - 'message' => 'Cannot query field "empty" on type "Result".', + 'message' => 'Internal server error', 'extensions' => [ - 'category' => 'graphql', + 'category' => 'internal', ], 'locations' => [ 0 => [ @@ -124,8 +124,16 @@ public function testEmptySchemaExtensionAlteredQueryResultPropertyAdded(): void 'column' => 37, ], ], + 'path' => [ + 'alterableQuery', + // Reference to our variable in the error. + 'empty', + ], ], ], + 'data' => [ + 'alterableQuery' => NULL, + ], ], json_decode($result->getContent(), TRUE)); } @@ -146,6 +154,7 @@ protected function mockSchema($id, $schema, array $extensions = []): void { $extensions['graphql_alterable_schema_test']->expects(static::any()) ->method('getBaseDefinition') ->willReturn(''); + // Different extension definition for different tests. // PHPUnit compatibility: remove once support for Drupal 10.2 is dropped. $methodName = method_exists($this, 'name') ? 'name' : 'getName';