You are here

public function CarouselServiceTest::testRenderImageById in bootstrap simple carousel 8

Tests the renderImageById() method.

@covers ::renderImageById

@dataProvider providerTestRenderImageById

File

tests/src/Unit/Service/CarouselServiceTest.php, line 68

Class

CarouselServiceTest
@coversDefaultClass \Drupal\bootstrap_simple_carousel\Service\CarouselService

Namespace

Drupal\Tests\bootstrap_simple_carousel\Unit\Service

Code

public function testRenderImageById(int $imageId, $file, string $imageStyle, array $params, array $with, int $renderCount, string $expected) {
  $storage = $this
    ->createMock(EntityStorageInterface::class);
  $storage
    ->expects($this
    ->once())
    ->method('load')
    ->with($imageId)
    ->willReturn($file);
  $this->entityTypeManager
    ->expects($this
    ->once())
    ->method('getStorage')
    ->willReturn($storage);
  $this->renderer
    ->expects($this
    ->exactly($renderCount))
    ->method('render')
    ->with($with)
    ->willReturn($expected);
  $carouselService = new CarouselService($this->renderer, $this->entityTypeManager);
  $actual = $carouselService
    ->renderImageById($imageId, $imageStyle, $params);
  $this
    ->assertSame($expected, $actual);
}