You are here

public function ImageStyleDependencyUpdateTest::testUpdateImageStyleDependencies in Drupal 8

Tests the updating of views dependencies to image styles.

File

core/modules/views/tests/src/Functional/Update/ImageStyleDependencyUpdateTest.php, line 29

Class

ImageStyleDependencyUpdateTest
Tests Views image style dependencies update.

Namespace

Drupal\Tests\views\Functional\Update

Code

public function testUpdateImageStyleDependencies() {
  $config_dependencies = View::load('foo')
    ->getDependencies()['config'];

  // Checks that 'thumbnail' image style is not a dependency of view 'foo'.
  $this
    ->assertFalse(in_array('image.style.thumbnail', $config_dependencies));

  // We test the case that the field formatter image style doesn't exist.
  // Checks that 'nonexistent' image style is not a dependency of view 'foo'.
  $this
    ->assertFalse(in_array('image.style.nonexistent', $config_dependencies));

  // Run updates.
  $this
    ->runUpdates();
  $config_dependencies = View::load('foo')
    ->getDependencies()['config'];

  // Checks that 'thumbnail' image style is a dependency of view 'foo'.
  $this
    ->assertTrue(in_array('image.style.thumbnail', $config_dependencies));

  // The 'nonexistent' style doesn't exist, thus is not a dependency. Checks
  // that 'nonexistent' image style is a not dependency of view 'foo'.
  $this
    ->assertFalse(in_array('image.style.nonexistent', $config_dependencies));
}