function ImageEffectsTest::testImageEffectsCaching

Same name in other branches
  1. 9 core/modules/image/tests/src/Kernel/ImageEffectsTest.php \Drupal\Tests\image\Kernel\ImageEffectsTest::testImageEffectsCaching()
  2. 10 core/modules/image/tests/src/Kernel/ImageEffectsTest.php \Drupal\Tests\image\Kernel\ImageEffectsTest::testImageEffectsCaching()
  3. 11.x core/modules/image/tests/src/Kernel/ImageEffectsTest.php \Drupal\Tests\image\Kernel\ImageEffectsTest::testImageEffectsCaching()

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.');
}

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