function ResponsiveImageLazyLoadUpdateTest::testUpdate

Same name in other branches
  1. 11.x core/modules/responsive_image/tests/src/Functional/ResponsiveImageLazyLoadUpdateTest.php \Drupal\Tests\responsive_image\Functional\ResponsiveImageLazyLoadUpdateTest::testUpdate()

Test new lazy-load setting upgrade path.

See also

responsive_image_post_update_image_loading_attribute

File

core/modules/responsive_image/tests/src/Functional/ResponsiveImageLazyLoadUpdateTest.php, line 36

Class

ResponsiveImageLazyLoadUpdateTest
Tests lazy-load upgrade path.

Namespace

Drupal\Tests\responsive_image\Functional

Code

public function testUpdate() : void {
    $data = EntityViewDisplay::load('node.article.default')->toArray();
    $this->assertArrayNotHasKey('image_loading', $data['content']['field_image']['settings']);
    $this->runUpdates();
    $data = EntityViewDisplay::load('node.article.default')->toArray();
    $this->assertArrayHasKey('image_loading', $data['content']['field_image']['settings']);
    $this->assertEquals('eager', $data['content']['field_image']['settings']['image_loading']['attribute']);
}

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