function ResponsiveImageLazyLoadUpdateTest::testEntitySave

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

Test responsive_image_entity_view_display_presave invokes deprecations.

@covers ::processResponsiveImageField

File

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

Class

ResponsiveImageLazyLoadUpdateTest
Tests lazy-load upgrade path.

Namespace

Drupal\Tests\responsive_image\Functional

Code

public function testEntitySave() : void {
    $this->expectDeprecation('The responsive image loading attribute update for "node.article.default" is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Configuration should be updated. See https://www.drupal.org/node/3279032');
    $view_display = EntityViewDisplay::load('node.article.default');
    $this->assertArrayNotHasKey('image_loading', $view_display->toArray()['content']['field_image']['settings']);
    $view_display->save();
    $view_display = EntityViewDisplay::load('node.article.default');
    $this->assertArrayHasKey('image_loading', $view_display->toArray()['content']['field_image']['settings']);
    $this->assertEquals('eager', $view_display->toArray()['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.