diff -u b/core/modules/system/src/Tests/Batch/PageTest.php b/core/modules/system/src/Tests/Batch/PageTest.php --- b/core/modules/system/src/Tests/Batch/PageTest.php +++ b/core/modules/system/src/Tests/Batch/PageTest.php @@ -3,6 +3,7 @@ namespace Drupal\system\Tests\Batch; use Drupal\simpletest\WebTestBase; +use Drupal\Core\Logger\RfcLogLevel; use Drupal\Core\Queue\DatabaseQueue; use Drupal\Core\Queue\BatchQueueInterface; @@ -77,8 +78,34 @@ * Tests that batch queue was wrongly implemented. */ public function testWrongQueueImplementation() { - $this->drupalGet('batch-test/test-wrong-queue'); - $this->assertErrorLogged('Batch queue "' . DatabaseQueue::class . '" is not implements "' . BatchQueueInterface::class . '" interface.'); + $message = sprintf('Batch queue "%s" is not implements "%s" interface.', DatabaseQueue::class, BatchQueueInterface::class); + $logger = \Drupal::service('logger.broken'); + $found = FALSE; + + batch_set([ + 'operations' => [ + ['dummy', []], + ], + 'queue' => [ + 'name' => 'test_wrong_batch_queue', + 'class' => DatabaseQueue::class, + ], + ]); + + batch_process(); + + foreach ($logger::$entries as $i => $entry) { + // Use non-strict comparison since "TranslatableMarkup" could + // be the value in "$entry['message']". + if ($entry['level'] === RfcLogLevel::EMERGENCY && $entry['message'] == $message) { + $found = TRUE; + + unset($logger::$entries[$i]); + break; + } + } + + $this->assertTrue($found, sprintf('Log entry "%s" about wrong queue implementation was found.', $message)); } } reverted: --- b/core/modules/system/tests/modules/batch_test/batch_test.routing.yml +++ a/core/modules/system/tests/modules/batch_test/batch_test.routing.yml @@ -85,10 +85,3 @@ _controller: '\Drupal\batch_test\Controller\BatchTestController::testTitleBatch' requirements: _access: 'TRUE' - -batch_test.test_wrong_queue: - path: '/batch-test/test-wrong-queue' - defaults: - _controller: '\Drupal\batch_test\Controller\BatchTestController::testWrongQueueImplementation' - requirements: - _access: 'TRUE' reverted: --- b/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php +++ a/core/modules/system/tests/modules/batch_test/src/Controller/BatchTestController.php @@ -3,7 +3,6 @@ namespace Drupal\batch_test\Controller; use Drupal\Core\Form\FormState; -use Drupal\Core\Queue\DatabaseQueue; /** * Controller routines for batch tests. @@ -143,23 +142,4 @@ return batch_process('batch-test/redirect'); } - /** - * Runs a batch for testing the wrong queue implementation. - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse|null - * A redirect response if the batch is progressive. No return value otherwise. - */ - public function testWrongQueueImplementation() { - batch_test_stack(NULL, TRUE); - $batch = [ - 'operations' => [], - 'queue' => [ - 'name' => 'test_wrong_batch_queue', - 'class' => DatabaseQueue::class, - ], - ]; - batch_set($batch); - return batch_process('batch-test/redirect'); - } - } only in patch2: unchanged: --- a/core/modules/system/tests/modules/error_service_test/src/Logger/TestLog.php +++ b/core/modules/system/tests/modules/error_service_test/src/Logger/TestLog.php @@ -11,12 +11,20 @@ * @see \Drupal\system\Tests\System\UncaughtExceptionTest::testLoggerException() */ class TestLog implements LoggerInterface { + use RfcLoggerTrait; /** + * An array of arrays with three items: "level", "context" and "message". + * + * @var array[] + */ + public static $entries = []; + + /** * {@inheritdoc} */ - public function log($level, $message, array $context = array()) { + public function log($level, $message, array $context = []) { $trigger = [ '%type' => 'Exception', '@message' => 'Deforestation', @@ -24,6 +32,13 @@ public function log($level, $message, array $context = array()) { 'severity_level' => 3, 'channel' => 'php', ]; + + static::$entries[] = [ + 'level' => $level, + 'message' => $message, + 'context' => $context, + ]; + if (array_diff_assoc($trigger, $context) === []) { throw new \Exception('Oh, oh, frustrated monkeys!'); }