function FilterImageLazyLoadTest::providerHtml

Same name and namespace in other branches
  1. 11.x core/modules/filter/tests/src/Unit/FilterImageLazyLoadTest.php \Drupal\Tests\filter\Unit\FilterImageLazyLoadTest::providerHtml()

Provides data for testProcess.

Return value

array An array of test data.

File

core/modules/filter/tests/src/Unit/FilterImageLazyLoadTest.php, line 49

Class

FilterImageLazyLoadTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21filter%21src%21Plugin%21Filter%21FilterImageLazyLoad.php/class/FilterImageLazyLoad/10" title="Provides a filter to lazy load tracked images." class="local">\Drupal\filter\Plugin\Filter\FilterImageLazyLoad</a> @group editor

Namespace

Drupal\Tests\filter\Unit

Code

public static function providerHtml() : array {
    return [
        'lazy loading attribute already added' => [
            'html' => '<p><img src="foo.png" loading="lazy"></p>',
            'expected' => '<p><img src="foo.png" loading="lazy"></p>',
        ],
        'eager loading attribute already added' => [
            'html' => '<p><img src="foo.png" loading="eager"/></p>',
            'expected' => '<p><img src="foo.png" loading="eager"></p>',
        ],
        'image dimensions provided' => [
            'html' => '<p><img src="foo.png" width="200" height="200"/></p>',
            'expected' => '<p><img src="foo.png" width="200" height="200" loading="lazy"></p>',
        ],
        'width image dimensions provided' => [
            'html' => '<p><img src="foo.png" width="200"/></p>',
            'expected' => '<p><img src="foo.png" width="200"></p>',
        ],
        'height image dimensions provided' => [
            'html' => '<p><img src="foo.png" height="200"/></p>',
            'expected' => '<p><img src="foo.png" height="200"></p>',
        ],
        'invalid loading attribute' => [
            'html' => '<p><img src="foo.png" width="200" height="200" loading="foo"></p>',
            'expected' => '<p><img src="foo.png" width="200" height="200" loading="lazy"></p>',
        ],
        'no image tag' => [
            'html' => '<p>Lorem ipsum...</p>',
            'expected' => '<p>Lorem ipsum...</p>',
        ],
        'no image dimensions provided' => [
            'html' => '<p><img src="foo.png"></p>',
            'expected' => '<p><img src="foo.png"></p>',
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.