ImageLoadingAttributeTest.php in Drupal 10
File
core/modules/system/tests/src/Functional/Theme/ImageLoadingAttributeTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Theme;
use Drupal\Tests\BrowserTestBase;
class ImageLoadingAttributeTest extends BrowserTestBase {
protected static $modules = [
'image_lazy_load_test',
];
protected $defaultTheme = 'stark';
public function testImageLoadingAttribute() {
$assert = $this
->assertSession();
$this
->drupalGet('image-lazy-load-test');
$assert
->elementAttributeExists('css', '#with-dimensions img', 'loading');
$assert
->elementAttributeContains('css', '#with-dimensions img', 'loading', 'lazy');
$assert
->elementAttributeContains('css', '#override-loading-attribute img', 'loading', 'eager');
$element = $assert
->elementExists('css', '#without-dimensions img');
$this
->assertFalse($element
->hasAttribute('loading'));
}
}