Issue #2751847 by penyaskito: Throw exception if the same service is injected twice in ChainedFastBackend

8.3.x
Alex Pott 2016-09-25 11:43:35 +01:00
parent f4c6a21986
commit e3587e21e4
2 changed files with 2 additions and 3 deletions

View File

@ -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;

View File

@ -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,