You are here

public function ImageUrlTest::setUp in GraphQL 8.4

Overrides GraphQLTestBase::setUp

File

tests/src/Kernel/DataProducer/Entity/Fields/Image/ImageUrlTest.php, line 20

Class

ImageUrlTest
Test class for the ImageUrl data producer.

Namespace

Drupal\Tests\graphql\Kernel\DataProducer\Entity\Fields\Image

Code

public function setUp() : void {
  parent::setUp();
  $this->dataProducerManager = $this->container
    ->get('plugin.manager.graphql.data_producer');
  $this->file_uri = 'public://test.jpg';
  $this->file_url = file_create_url($this->file_uri);
  $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_not_accessible = $this
    ->getMockBuilder(FileInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $this->file_not_accessible
    ->method('access')
    ->willReturn((new AccessResultForbidden())
    ->addCacheTags([
    'test_tag_forbidden',
  ]));
}