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 @@ -18,7 +18,7 @@ * * @var array */ - public static $modules = array('batch_test'); + public static $modules = array('error_service_test', 'batch_test'); /** * Tests that the batch API progress page uses the correct theme. @@ -77,6 +77,7 @@ * 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.'); } only in patch2: unchanged: --- a/core/modules/simpletest/src/TestBase.php +++ b/core/modules/simpletest/src/TestBase.php @@ -808,7 +808,7 @@ protected function assertIdenticalObject($object1, $object2, $message = '', $gro protected function assertNoErrorsLogged() { // Since PHP only creates the error.log file when an actual error is // triggered, it is sufficient to check whether the file exists. - return $this->assertFalse(file_exists(DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log'), 'PHP error.log is empty.'); + return $this->assertFalse(file_exists(ini_get('error_log')), 'PHP error.log is empty.'); } /** @@ -821,30 +821,32 @@ protected function assertNoErrorsLogged() { * TRUE if the assertion succeeded, FALSE otherwise. * * @see \Drupal\simpletest\TestBase::prepareEnvironment() - * @see \Drupal\Core\DrupalKernel::bootConfiguration() + * @see \Drupal\Core\DrupalKernel::bootEnvironment() */ protected function assertErrorLogged($error_message) { - $error_log_filename = DRUPAL_ROOT . '/' . $this->siteDirectory . '/error.log'; - if (!file_exists($error_log_filename)) { - $this->error('No error logged yet.'); - } + $error_log_filename = ini_get('error_log'); + // We iterate over the rows in order to be able to remove the logged + // errors afterwards. + $found = FALSE; - $content = file_get_contents($error_log_filename); - $rows = explode(PHP_EOL, $content); + if (file_exists($error_log_filename)) { + $content = file_get_contents($error_log_filename); + $rows = explode(PHP_EOL, $content); - // We iterate over the rows in order to be able to remove the logged error - // afterwards. - $found = FALSE; - foreach ($rows as $row_index => $row) { - if (strpos($content, $error_message) !== FALSE) { - $found = TRUE; - unset($rows[$row_index]); + foreach ($rows as $row_index => $row) { + if (strpos($content, $error_message) !== FALSE) { + $found = TRUE; + unset($rows[$row_index]); + } } - } - file_put_contents($error_log_filename, implode("\n", $rows)); + file_put_contents($error_log_filename, implode("\n", $rows)); + } + else { + $this->error('No error logged yet.'); + } - return $this->assertTrue($found, sprintf('The %s error message was logged.', $error_message)); + return $this->assertTrue($found, sprintf('The "%s" error message was logged.', $error_message)); } /** only in patch2: unchanged: --- a/core/modules/system/tests/modules/batch_test/batch_test.routing.yml +++ b/core/modules/system/tests/modules/batch_test/batch_test.routing.yml @@ -85,3 +85,10 @@ batch_test.test_title: _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'