You are here

protected function BlazyManagerUnitTestTrait::setUpImageStyle in Blazy 8

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

Prepare image styles.

1 call to BlazyManagerUnitTestTrait::setUpImageStyle()
BlazyManagerUnitTest::testEntityLoadImageStyle in tests/src/Unit/BlazyManagerUnitTest.php
Tests cases for config.

File

tests/src/Traits/BlazyManagerUnitTestTrait.php, line 73

Class

BlazyManagerUnitTestTrait
A Trait common for Blazy related service managers.

Namespace

Drupal\Tests\blazy\Traits

Code

protected function setUpImageStyle() {
  $styles = [];
  $dummies = [
    'blazy_crop',
    'large',
    'medium',
    'small',
  ];
  foreach ($dummies as $style) {
    $mock = $this
      ->createMock('Drupal\\Core\\Config\\Entity\\ConfigEntityInterface');
    $mock
      ->expects($this
      ->any())
      ->method('getCacheTags')
      ->willReturn([]);
    $styles[$style] = $mock;
  }
  $ids = array_keys($styles);
  $storage = $this
    ->createMock('\\Drupal\\Core\\Config\\Entity\\ConfigEntityStorageInterface');
  $storage
    ->expects($this
    ->any())
    ->method('loadMultiple')
    ->with($ids)
    ->willReturn($styles);
  $style = 'large';
  $storage
    ->expects($this
    ->any())
    ->method('load')
    ->with($style)
    ->will($this
    ->returnValue($styles[$style]));
  $this->entityTypeManager
    ->expects($this
    ->any())
    ->method('getStorage')
    ->with('image_style')
    ->willReturn($storage);
  return $styles;
}