public function ImageDerivativeTest::testImageDerivative in GraphQL 8.4
@covers \Drupal\graphql\Plugin\GraphQL\DataProducer\Entity\Fields\Image\ImageDerivative::resolve
File
- tests/
src/ Kernel/ DataProducer/ Entity/ Fields/ Image/ ImageDerivativeTest.php, line 62
Class
- ImageDerivativeTest
- Test class for the ImageDerivative data producer.
Namespace
Drupal\Tests\graphql\Kernel\DataProducer\Entity\Fields\ImageCode
public function testImageDerivative() : void {
// Test that we get the proper style and dimensions if we have access to the
// file.
$result = $this
->executeDataProducer('image_derivative', [
'entity' => $this->file,
'style' => 'test_style',
]);
$this
->assertEquals([
'url' => $this->style
->buildUrl($this->file_uri),
'width' => 300,
'height' => 200,
], $result);
// @todo Add cache checks.
// $this->assertContains('config:image.style.test_style',
// $metadata->getCacheTags());
// $this->assertContains('test_tag', $metadata->getCacheTags());
// Test that we don't get the derivative if we don't have access to the
// original file, but we still get the access result cache tags.
$result = $this
->executeDataProducer('image_derivative', [
'entity' => $this->file_not_accessible,
'style' => 'test_style',
]);
$this
->assertNull($result);
// @todo Add cache checks.
// $this->assertContains('test_tag_forbidden',
// $metadata->getCacheTags());
}