You are here

protected function BlazyUnitTestTrait::setUpMockImage in Blazy 8

Same name and namespace in other branches
  1. 8.2 tests/src/Traits/BlazyUnitTestTrait.php \Drupal\Tests\blazy\Traits\BlazyUnitTestTrait::setUpMockImage()

Setup the unit images.

1 call to BlazyUnitTestTrait::setUpMockImage()
BlazyUnitTest::setUp in tests/src/Unit/BlazyUnitTest.php

File

tests/src/Traits/BlazyUnitTestTrait.php, line 318

Class

BlazyUnitTestTrait
A Trait common for Blazy Unit tests.

Namespace

Drupal\Tests\blazy\Traits

Code

protected function setUpMockImage() {
  $entity = $this
    ->createMock('\\Drupal\\Core\\Entity\\ContentEntityInterface');
  $entity
    ->expects($this
    ->any())
    ->method('label')
    ->willReturn($this
    ->randomMachineName());
  $entity
    ->expects($this
    ->any())
    ->method('getEntityTypeId')
    ->will($this
    ->returnValue('node'));
  $item = $this
    ->createMock('\\Drupal\\Core\\Field\\FieldItemListInterface');
  $item
    ->expects($this
    ->any())
    ->method('getEntity')
    ->willReturn($entity);
  $this
    ->setUpUnitImages();
  $this->testItem = $item;
  $this->data['item'] = $item;
  $item->entity = $entity;
}