You are here

public function ResponsiveImageTest::testMultipleImages in Image Lazyloader 8

Tests multiple images.

@covers ::count @covers ::parse

File

tests/src/Unit/ResponsiveImageTest.php, line 69

Class

ResponsiveImageTest
@coversDefaultClass \Drupal\lazyloader\ResponsiveImage @group lazyloader

Namespace

Drupal\Tests\lazyloader\Unit

Code

public function testMultipleImages() {
  $string = 'small.jpg 500w,
		medium.jpg 3x,

  big.jpg 1024w';
  $image = ResponsiveImage::parse($string);
  $this
    ->assertCount(3, $image);
  $this
    ->assertEquals('small.jpg', $image
    ->get(0)->uri);
  $this
    ->assertEquals('medium.jpg', $image
    ->get(1)->uri);
  $this
    ->assertEquals('big.jpg', $image
    ->get(2)->uri);
  $this
    ->assertEquals('500', $image
    ->get(0)->width);
  $this
    ->assertNull($image
    ->get(1)->width);
  $this
    ->assertEquals('1024', $image
    ->get(2)->width);
  $this
    ->assertNull($image
    ->get(0)->density);
  $this
    ->assertEquals('3', $image
    ->get(1)->density);
  $this
    ->assertNull($image
    ->get(2)->density);
  return $image;
}