function ImageLazyLoadUpdateTest::testUpdate

Test new lazy-load setting upgrade path.

See also

image_post_update_image_loading_attribute

File

core/modules/image/tests/src/Functional/ImageLazyLoadUpdateTest.php, line 28

Class

ImageLazyLoadUpdateTest
Tests lazy-load upgrade path.

Namespace

Drupal\Tests\image\Functional

Code

public function testUpdate() {
    $storage = \Drupal::entityTypeManager()->getStorage('entity_view_display');
    
    /** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display */
    $view_display = $storage->load('node.article.default');
    $component = $view_display->getComponent('field_image');
    $this->assertArrayNotHasKey('image_loading', $component['settings']);
    $this->runUpdates();
    $view_display = $storage->load('node.article.default');
    $component = $view_display->getComponent('field_image');
    $this->assertArrayHasKey('image_loading', $component['settings']);
    $this->assertEquals('lazy', $component['settings']['image_loading']['attribute']);
}

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