diff --git a/core/modules/simpletest/simpletest.api.php b/core/modules/simpletest/simpletest.api.php index 9b9014e5ad1..d8f82094601 100644 --- a/core/modules/simpletest/simpletest.api.php +++ b/core/modules/simpletest/simpletest.api.php @@ -36,14 +36,6 @@ function hook_simpletest_alter(&$groups) { * A test group has started. * * This hook is called just once at the beginning of a test group. - * - * This hook is only invoked by the Simpletest UI form runner. It will not be - * invoked by run-tests.sh or the phpunit tool. - * - * @deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.0. Convert - * your test to a PHPUnit-based one and implement test listeners. - * - * @see https://www.drupal.org/node/2934242 */ function hook_test_group_started() { } @@ -52,14 +44,6 @@ function hook_test_group_started() { * A test group has finished. * * This hook is called just once at the end of a test group. - * - * This hook is only invoked by the Simpletest UI form runner. It will not be - * invoked by run-tests.sh or the phpunit tool. - * - * @deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.0. Convert - * your test to a PHPUnit-based one and implement test listeners. - * - * @see https://www.drupal.org/node/2934242 */ function hook_test_group_finished() { } @@ -69,19 +53,11 @@ function hook_test_group_finished() { * * This hook is called when an individual test has finished. * - * This hook is only invoked by the Simpletest UI form runner. It will not be - * invoked by run-tests.sh or the phpunit tool. - * * @param * $results The results of the test as gathered by * \Drupal\simpletest\WebTestBase. * * @see \Drupal\simpletest\WebTestBase::results() - * - * @deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.0. Convert - * your test to a PHPUnit-based one and implement test listeners. - * - * @see https://www.drupal.org/node/2934242 */ function hook_test_finished($results) { } diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index 1d0e7b2cb70..1d21118caca 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -161,7 +161,7 @@ function simpletest_run_tests($test_list) { ]; batch_set($batch); - \Drupal::moduleHandler()->invokeAllDeprecated('Convert your test to a PHPUnit-based one and implement test listeners. See https://www.drupal.org/node/2934242', 'test_group_started'); + \Drupal::moduleHandler()->invokeAll('test_group_started'); return $test_id; } @@ -428,7 +428,7 @@ function _simpletest_batch_operation($test_list_init, $test_id, &$context) { else { $test = new $test_class($test_id); $test->run(); - \Drupal::moduleHandler()->invokeAllDeprecated('Convert your test to a PHPUnit-based one and implement test listeners. See https://www.drupal.org/node/2934242', 'test_finished', [$test->results]); + \Drupal::moduleHandler()->invokeAll('test_finished', [$test->results]); $test_results[$test_class] = $test->results; } $size = count($test_list); @@ -490,7 +490,7 @@ function _simpletest_batch_finished($success, $results, $operations, $elapsed) { \Drupal::messenger()->addError(t('The test run did not successfully finish.')); \Drupal::messenger()->addWarning(t('Use the Clean environment button to clean-up temporary files and tables.')); } - \Drupal::moduleHandler()->invokeAllDeprecated('Convert your test to a PHPUnit-based one and implement test listeners. See https://www.drupal.org/node/2934242', 'test_group_finished'); + \Drupal::moduleHandler()->invokeAll('test_group_finished'); } /** diff --git a/core/modules/simpletest/tests/modules/simpletest_deprecation_test/simpletest_deprecation_test.module b/core/modules/simpletest/tests/modules/simpletest_deprecation_test/simpletest_deprecation_test.module index d0f01eb7a62..f61059783c0 100644 --- a/core/modules/simpletest/tests/modules/simpletest_deprecation_test/simpletest_deprecation_test.module +++ b/core/modules/simpletest/tests/modules/simpletest_deprecation_test/simpletest_deprecation_test.module @@ -13,30 +13,3 @@ function simpletest_deprecation_test_simpletest_alter(&$groups) { // No-op. } - -/** - * Implements hook_test_group_started(). - * - * This hook is deprecated and should trigger a deprecation error when invoked. - */ -function simpletest_deprecation_test_test_group_started() { - // No-op. -} - -/** - * Implements hook_test_group_finished(). - * - * This hook is deprecated and should trigger a deprecation error when invoked. - */ -function simpletest_deprecation_test_test_group_finished() { - // No-op. -} - -/** - * Implements hook_test_finished(). - * - * This hook is deprecated and should trigger a deprecation error when invoked. - */ -function simpletest_deprecation_test_test_finished($results) { - // No-op. -} diff --git a/core/modules/simpletest/tests/src/Kernel/TestDeprecatedTestHooks.php b/core/modules/simpletest/tests/src/Kernel/TestDeprecatedTestHooks.php deleted file mode 100644 index 67ea81697e4..00000000000 --- a/core/modules/simpletest/tests/src/Kernel/TestDeprecatedTestHooks.php +++ /dev/null @@ -1,143 +0,0 @@ -getMockBuilder(Insert::class) - ->disableOriginalConstructor() - ->setMethods(['execute', 'useDefaults']) - ->getMock(); - $insert->expects($this->any()) - ->method('useDefaults') - ->willReturn($insert); - $insert->expects($this->any()) - ->method('execute') - // Return an arbitrary test ID. - ->willReturn(__METHOD__); - - $connection = $this->getMockBuilder(Connection::class) - ->disableOriginalConstructor() - ->setMethods(['insert']) - ->getMockForAbstractClass(); - $connection->expects($this->once()) - ->method('insert') - ->willReturn($insert); - - // Mock public stream wrapper enough for simpletest_run_tests(). - $public = $this->getMockBuilder(PublicStream::class) - ->disableOriginalConstructor() - // Mock all methods to do nothing and return NULL. - ->setMethods([]) - ->getMock(); - - // Set up the container. - $this->container->set('database', $connection); - $this->container->set('stream_wrapper.public', $public); - - // Make sure our mocked database is in use by expecting a test ID that is - // __METHOD__. - $this->assertEquals(__METHOD__, simpletest_run_tests([static::class])); - } - - /** - * @expectedDeprecation The deprecated hook hook_test_finished() is implemented in these functions: simpletest_deprecation_test_test_finished(). Convert your test to a PHPUnit-based one and implement test listeners. See https://www.drupal.org/node/2934242 - */ - public function testHookTestFinished() { - // Mock test_discovery. - $discovery = $this->getMockBuilder(TestDiscovery::class) - ->disableOriginalConstructor() - ->setMethods(['registerTestNamespaces']) - ->getMock(); - $discovery->expects($this->any()) - ->method('registerTestNamespaces') - ->willReturn([]); - - // Mock renderer. - $renderer = $this->getMockBuilder(Renderer::class) - ->disableOriginalConstructor() - ->setMethods(['render']) - ->getMock(); - // We don't care what the rendered batch elements look like. - $renderer->expects($this->any()) - ->method('render') - ->willReturn(''); - - // Set up the container. - $this->container->set('test_discovery', $discovery); - $this->container->set('renderer', $renderer); - - // A mock batch. - $context = []; - - // InnocuousTest is a WebTestBase test class which passes and never touches - // the database. - _simpletest_batch_operation([InnocuousTest::class], __METHOD__, $context); - } - -} - -/** - * A very simple WebTestBase test that never touches the database. - * - * @group WebTestBase - * @group legacy - */ -class InnocuousTest extends WebTestBase { - - /** - * Override to prevent any environmental side-effects. - */ - protected function prepareEnvironment() { - } - - /** - * Override run() since it uses TestBase. - */ - public function run(array $methods = []) { - } - - /** - * Override to prevent any assertions from being stored. - */ - protected function storeAssertion(array $assertion) { - } - - /** - * Override to prevent any assertions from being stored. - */ - public static function insertAssert($test_id, $test_class, $status, $message = '', $group = 'Other', array $caller = []) { - } - -}