class ImageLazyLoadUpdateTest

Tests lazy-load upgrade path.

@group image

Hierarchy

Expanded class hierarchy of ImageLazyLoadUpdateTest

File

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

Namespace

Drupal\Tests\image\Functional
View source
class ImageLazyLoadUpdateTest extends UpdatePathTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected function setDatabaseDumpFiles() {
    $this->databaseDumpFiles = [
      __DIR__ . '/../../../../system/tests/fixtures/update/drupal-9.3.0.filled.standard.php.gz',
    ];
  }
  
  /**
   * Test new lazy-load setting upgrade path.
   *
   * @see image_post_update_image_loading_attribute
   */
  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.