Issue #2751847 by penyaskito: Throw exception if the same service is injected twice in ChainedFastBackend
parent
f4c6a21986
commit
e3587e21e4
|
@ -94,8 +94,7 @@ class ChainedFastBackend implements CacheBackendInterface, CacheTagsInvalidatorI
|
|||
*/
|
||||
public function __construct(CacheBackendInterface $consistent_backend, CacheBackendInterface $fast_backend, $bin) {
|
||||
if ($consistent_backend == $fast_backend) {
|
||||
// @todo: should throw a proper exception. See https://www.drupal.org/node/2751847.
|
||||
trigger_error('Consistent cache backend and fast cache backend cannot use the same service.', E_USER_ERROR);
|
||||
throw new \Exception('Consistent cache backend and fast cache backend cannot use the same service.');
|
||||
}
|
||||
$this->consistentBackend = $consistent_backend;
|
||||
$this->fastBackend = $fast_backend;
|
||||
|
|
|
@ -39,7 +39,7 @@ class ChainedFastBackendTest extends UnitTestCase {
|
|||
*/
|
||||
public function testConsistentAndFastBackendCannotBeTheSameService() {
|
||||
// ToDo: It should throw a proper exception. See https://www.drupal.org/node/2751847.
|
||||
$this->setExpectedException(\PHPUnit_Framework_Error::class, 'Consistent cache backend and fast cache backend cannot use the same service.');
|
||||
$this->setExpectedException(\Exception::class, 'Consistent cache backend and fast cache backend cannot use the same service.');
|
||||
$cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
|
||||
$chained_fast_backend = new ChainedFastBackend(
|
||||
$cache,
|
||||
|
|
Loading…
Reference in New Issue