function AccessResultTest::testCacheUntilConfigurationChanges

@expectedDeprecation Drupal\Core\Access\AccessResult::cacheUntilConfigurationChanges is deprecated in drupal:8.0.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Access\AccessResult::addCacheableDependency() instead. @group legacy

File

core/tests/Drupal/Tests/Core/Access/AccessResultTest.php, line 992

Class

AccessResultTest
@coversDefaultClass \Drupal\Core\Access\AccessResult @group Access

Namespace

Drupal\Tests\Core\Access

Code

public function testCacheUntilConfigurationChanges() {
    $config = $this->prophesize(Config::class);
    $config->getCacheContexts()
        ->willReturn([
        'context',
    ]);
    $config->getCacheTags()
        ->willReturn([
        'tag',
    ]);
    $config->getCacheMaxAge()
        ->willReturn(10);
    $access_result = AccessResult::neutral()->cacheUntilConfigurationChanges($config->reveal());
    $this->assertSame([
        'context',
    ], $access_result->getCacheContexts());
    $this->assertSame([
        'tag',
    ], $access_result->getCacheTags());
    $this->assertSame(10, $access_result->getCacheMaxAge());
}

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