public function ImageDerivativeTest::setUp in GraphQL 8.4
Overrides GraphQLTestBase::setUp
File
- tests/
src/ Kernel/ DataProducer/ Entity/ Fields/ Image/ ImageDerivativeTest.php, line 26
Class
- ImageDerivativeTest
- Test class for the ImageDerivative data producer.
Namespace
Drupal\Tests\graphql\Kernel\DataProducer\Entity\Fields\ImageCode
public function setUp() : void {
parent::setUp();
$this->file_uri = 'public://test.jpg';
$this->file = $this
->getMockBuilder(FileInterface::class)
->disableOriginalConstructor()
->getMock();
$this->file
->method('getFileUri')
->willReturn($this->file_uri);
$this->file
->method('access')
->willReturn((new AccessResultAllowed())
->addCacheTags([
'test_tag',
]));
$this->file->width = 600;
$this->file->height = 400;
$this->style = ImageStyle::create([
'name' => 'test_style',
]);
$effect = [
'id' => 'image_resize',
'data' => [
'width' => 300,
'height' => 200,
],
];
$this->style
->addImageEffect($effect);
$this->style
->save();
$this->file_not_accessible = $this
->getMockBuilder(FileInterface::class)
->disableOriginalConstructor()
->getMock();
$this->file_not_accessible
->method('access')
->willReturn((new AccessResultForbidden())
->addCacheTags([
'test_tag_forbidden',
]));
}