You are here

public function AccessResultTest::testCacheUntilEntityChanges in Drupal 8

@expectedDeprecation Drupal\Core\Access\AccessResult::cacheUntilEntityChanges 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 977
Contains \Drupal\Tests\Core\Access\AccessResultTest.

Class

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

Namespace

Drupal\Tests\Core\Access

Code

public function testCacheUntilEntityChanges() {
  $entity = $this
    ->prophesize(EntityInterface::class);
  $entity
    ->getCacheContexts()
    ->willReturn([
    'context',
  ]);
  $entity
    ->getCacheTags()
    ->willReturn([
    'tag',
  ]);
  $entity
    ->getCacheMaxAge()
    ->willReturn(10);
  $access_result = AccessResult::neutral()
    ->cacheUntilEntityChanges($entity
    ->reveal());
  $this
    ->assertSame([
    'context',
  ], $access_result
    ->getCacheContexts());
  $this
    ->assertSame([
    'tag',
  ], $access_result
    ->getCacheTags());
  $this
    ->assertSame(10, $access_result
    ->getCacheMaxAge());
}