Commit e3587e21 authored by alexpott's avatar alexpott

Issue #2751847 by penyaskito: Throw exception if the same service is injected...

Issue #2751847 by penyaskito: Throw exception if the same service is injected twice in ChainedFastBackend
parent f4c6a219
......@@ -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,
......
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