You are here

public function ExcludeTestCase::testImageStyleExclude in Image Lazyloader 8

Test functioning of the image style exclude setting.

File

src/tests/ExcludeTestCase.php, line 88

Class

ExcludeTestCase
Tests Lazyloader's exclusion functionality.

Namespace

Drupal\lazyloader\Tests

Code

public function testImageStyleExclude() {

  // Test default rendering of a node.
  $this
    ->drupalGet("node/{$this->node->nid}");
  $this
    ->assertLazyloaderEnabled();

  // Enable exclusion option, but don't disable the current image style.
  $edit['lazyloader_image_styles[medium]'] = 'medium';
  $this
    ->drupalPost("admin/config/media/lazyloader/exclude", $edit, t('Save configuration'));
  $this
    ->drupalGet("node/{$this->node->nid}");
  $this
    ->assertLazyloaderEnabled(TRUE, 'Lazyloader is enabled for <em>medium</em> image style.');

  // Enable exclusion option, now excluding the current image style.
  $edit['lazyloader_image_styles[medium]'] = FALSE;
  $edit['lazyloader_image_styles[large]'] = 'large';
  $this
    ->drupalPost("admin/config/media/lazyloader/exclude", $edit, t('Save configuration'));
  $this
    ->drupalGet("node/{$this->node->nid}");
  $this
    ->assertLazyloaderEnabled(FALSE, 'Lazyloader is disabled for <em>medium</em> image style.');

  // @todo test that image style exclusion only affects images using an image
  // style.
}