Commit 1643a70e authored by catch's avatar catch

Issue #3111504 by andypost, longwave, Berdir: Properly deprecate...

Issue #3111504 by andypost, longwave, Berdir: Properly deprecate AccessResult::cacheUntilEntityChanges()

(cherry picked from commit c2ee4cd512ec669784a1f74261a381844034e6b9)
parent ff35c345
......@@ -290,6 +290,7 @@ public function cachePerUser() {
* ::addCacheableDependency() instead.
*/
public function cacheUntilEntityChanges(EntityInterface $entity) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:8.0.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Access\AccessResult::addCacheableDependency() instead.', E_USER_DEPRECATED);
return $this->addCacheableDependency($entity);
}
......
......@@ -15,6 +15,7 @@
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Config\Config;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Tests\UnitTestCase;
/**
......@@ -969,6 +970,21 @@ public function providerTestAllowedIfHasPermissions() {
return $data;
}
/**
* @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
*/
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());
}
/**
* @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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment