Commit d208812e authored by alexpott's avatar alexpott

Issue #2460521 by Mile23, chx, mgifford, dawehner, larowlan: Deprecate hook_simpletest_alter()

parent 2708ff78
......@@ -13,10 +13,17 @@
/**
* Alter the list of tests.
*
* This hook will not be invoked by the phpunit tool.
*
* @param $groups
* A two dimensional array, the first key is the test group, the second is the
* name of the test class, and the value is in associative array containing
* 'name', 'description', 'group', and 'requires' keys.
*
* @deprecated in Drupal 8.6.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/2939892
*/
function hook_simpletest_alter(&$groups) {
// An alternative session handler module would not want to run the original
......
......@@ -213,7 +213,7 @@ public function getTestClasses($extension = NULL, array $types = []) {
}
// Allow modules extending core tests to disable originals.
$this->moduleHandler->alter('simpletest', $list);
$this->moduleHandler->alterDeprecated('Convert your test to a PHPUnit-based one and implement test listeners. See: https://www.drupal.org/node/2939892', 'simpletest', $list);
if (!isset($extension)) {
if ($this->cacheBackend) {
......
name: 'Simpletest deprecation test'
type: module
description: 'Support module for Simpletest deprecation tests.'
package: Testing
version: VERSION
core: 8.x
<?php
/**
* @file
* Mock module for testing simpletest.
*/
/**
* Implements hook_simpletest_alter().
*
* This hook is deprecated and should trigger a deprecation error when invoked.
*/
function simpletest_deprecation_test_simpletest_alter(&$groups) {
// No-op.
}
<?php
namespace Drupal\Tests\simpletest\Kernel;
use Drupal\KernelTests\KernelTestBase;
/**
* @group simpletest
* @group legacy
*
* @coversDefaultClass \Drupal\simpletest\TestDiscovery
*/
class TestDiscoveryDeprecationTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['simpletest', 'simpletest_deprecation_test'];
/**
* @expectedDeprecation The deprecated alter hook hook_simpletest_alter() is implemented in these functions: simpletest_deprecation_test_simpletest_alter. Convert your test to a PHPUnit-based one and implement test listeners. See: https://www.drupal.org/node/2939892
* @covers ::getTestClasses
*/
public function testHookSimpletestAlter() {
// The simpletest_test module implements hook_simpletest_alter(), which
// should trigger a deprecation error during getTestClasses().
$this->assertNotEmpty(
$this->container->get('test_discovery')->getTestClasses()
);
}
}
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