function CacheableMetadataCalculationTest::assertCacheableMetadataHasBeenCalculated

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Kernel/CacheableMetadataCalculationTest.php \Drupal\Tests\views\Kernel\CacheableMetadataCalculationTest::assertCacheableMetadataHasBeenCalculated()
  2. 10 core/modules/views/tests/src/Kernel/CacheableMetadataCalculationTest.php \Drupal\Tests\views\Kernel\CacheableMetadataCalculationTest::assertCacheableMetadataHasBeenCalculated()
  3. 11.x core/modules/views/tests/src/Kernel/CacheableMetadataCalculationTest.php \Drupal\Tests\views\Kernel\CacheableMetadataCalculationTest::assertCacheableMetadataHasBeenCalculated()

Checks whether the view has calculated its cacheability metadata.

@internal

Parameters

bool $expected_result: TRUE if it is expected that the cacheability metadata has been calculated. FALSE otherwise.

1 call to CacheableMetadataCalculationTest::assertCacheableMetadataHasBeenCalculated()
CacheableMetadataCalculationTest::testCacheableMetadataCalculation in core/modules/views/tests/src/Kernel/CacheableMetadataCalculationTest.php
Tests that cacheability metadata is only calculated when needed.

File

core/modules/views/tests/src/Kernel/CacheableMetadataCalculationTest.php, line 101

Class

CacheableMetadataCalculationTest
Tests that cacheability metadata is only calculated when needed.

Namespace

Drupal\Tests\views\Kernel

Code

protected function assertCacheableMetadataHasBeenCalculated(bool $expected_result) : void {
    $this->state
        ->resetCache();
    $this->assertEquals($expected_result, $this->state
        ->get('views_test_cacheable_metadata_has_been_accessed'));
}

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