You are here

private function PageContextTest::testGetAllWithSetByNodeSetUpThumbnailUrl in Acquia Lift Connector 8

testGetAllWithSetByNode(), sub routine "set up thumbnail url".

Parameters

$node Node:

1 call to PageContextTest::testGetAllWithSetByNodeSetUpThumbnailUrl()
PageContextTest::testGetAllWithSetByNode in tests/src/Unit/Service/Context/PageContextTest.php
Tests the getAll() method, with setByNode().

File

tests/src/Unit/Service/Context/PageContextTest.php, line 219
Contains \Drupal\Tests\acquia_lift\Service\Context\PageContextTest.

Class

PageContextTest
PageContextTest Test.

Namespace

Drupal\Tests\acquia_lift\Service\Context

Code

private function testGetAllWithSetByNodeSetUpThumbnailUrl($node) {
  $field_media = $this
    ->getMockBuilder('Drupal\\Core\\Entity\\ContentEntityInterface')
    ->disableOriginalConstructor()
    ->getMock();
  $field_image = $this
    ->getMockBuilder('Drupal\\Core\\Entity\\ContentEntityInterface')
    ->disableOriginalConstructor()
    ->getMock();
  $media_entity = $this
    ->getMock('Drupal\\Core\\Entity\\EntityInterface');
  $image_entity = $this
    ->getMock('Drupal\\file\\FileInterface');
  $node->field_media = $field_media;
  $node->field_media->entity = $media_entity;
  $node->field_media->entity->field_image = $field_image;
  $node->field_media->entity->field_image->entity = $image_entity;
  $entity_manager = $this
    ->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
  $entity_storage = $this
    ->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
  $container = $this
    ->getMock('Drupal\\Core\\DependencyInjection\\Container');
  $image_style = $this
    ->getMockBuilder('Drupal\\image\\Entity\\ImageStyle')
    ->disableOriginalConstructor()
    ->getMock();
  \Drupal::setContainer($container);
  $container
    ->expects($this
    ->any())
    ->method('get')
    ->with('entity.manager')
    ->willReturn($entity_manager);
  $entity_manager
    ->expects($this
    ->once())
    ->method('getEntityTypeFromClass')
    ->with('Drupal\\image\\Entity\\ImageStyle')
    ->willReturn($image_entity);
  $image_entity
    ->expects($this
    ->once())
    ->method('bundle')
    ->willReturn('file');
  $image_entity
    ->expects($this
    ->once())
    ->method('getFileUri')
    ->willReturn('a_file_uri');
  $entity_manager
    ->expects($this
    ->once())
    ->method('getStorage')
    ->with($image_entity)
    ->willReturn($entity_storage);
  $entity_storage
    ->expects($this
    ->once())
    ->method('load')
    ->with('medium')
    ->willReturn($image_style);
  $image_style
    ->expects($this
    ->once())
    ->method('buildUrl')
    ->with('a_file_uri')
    ->willReturn('a_style_decorated_file_uri');
}