You are here

public function ImageEffectsTest::testImageEffectsCaching in Drupal 8

Test image effect caching.

File

core/modules/image/tests/src/Functional/ImageEffectsTest.php, line 176

Class

ImageEffectsTest
Tests that the image effects pass parameters to the toolkit correctly.

Namespace

Drupal\Tests\image\Functional

Code

public function testImageEffectsCaching() {
  $image_effect_definitions_called =& drupal_static('image_module_test_image_effect_info_alter');

  // First call should grab a fresh copy of the data.
  $manager = $this->container
    ->get('plugin.manager.image.effect');
  $effects = $manager
    ->getDefinitions();
  $this
    ->assertTrue($image_effect_definitions_called === 1, 'image_effect_definitions() generated data.');

  // Second call should come from cache.
  drupal_static_reset('image_module_test_image_effect_info_alter');
  $cached_effects = $manager
    ->getDefinitions();
  $this
    ->assertTrue($image_effect_definitions_called === 0, 'image_effect_definitions() returned data from cache.');
  $this
    ->assertTrue($effects == $cached_effects, 'Cached effects are the same as generated effects.');
}