class DeprecationHelperTest
Same name in other branches
- 10 core/tests/Drupal/Tests/Component/Utility/DeprecationHelperTest.php \Drupal\Tests\Component\Utility\DeprecationHelperTest
@coversDefaultClass \Drupal\Component\Utility\DeprecationHelper @group Utility
Hierarchy
- class \Drupal\Tests\Component\Utility\DeprecationHelperTest extends \PHPUnit\Framework\TestCase
Expanded class hierarchy of DeprecationHelperTest
File
-
core/
tests/ Drupal/ Tests/ Component/ Utility/ DeprecationHelperTest.php, line 14
Namespace
Drupal\Tests\Component\UtilityView source
class DeprecationHelperTest extends TestCase {
/**
* @param string $currentVersion
* The core version to test against.
* @param array $tests
* Array of versions and their expected result.
*
* @dataProvider deprecatedHelperTestCases
*/
public function testDeprecationHelper(string $currentVersion, array $tests) : void {
foreach ($tests as $deprecatedVersion => $expectedCallable) {
$result = DeprecationHelper::backwardsCompatibleCall($currentVersion, $deprecatedVersion, fn() => 'current', fn() => 'deprecated');
$this->assertEquals($expectedCallable, $result, "Change introduced in {$deprecatedVersion} should return {$expectedCallable} for core version {$currentVersion}");
}
}
public static function deprecatedHelperTestCases() : array {
return [
[
'currentVersion' => '10.2.x-dev',
'tests' => [
'11.0.0' => 'deprecated',
'10.3.0' => 'deprecated',
'10.2.1' => 'deprecated',
'10.2.0' => 'current',
'10.1.0' => 'current',
'10.0.0' => 'current',
'9.5.0' => 'current',
],
],
[
'currentVersion' => '10.2.1',
'tests' => [
'11.0.0' => 'deprecated',
'10.2.2' => 'deprecated',
'10.2.1' => 'current',
'10.2.0' => 'current',
'10.1.0' => 'current',
'10.0.0' => 'current',
'9.5.0' => 'current',
],
],
[
'currentVersion' => '11.0-dev',
'tests' => [
'11.5.0' => 'deprecated',
'11.0.1' => 'deprecated',
'11.0.0' => 'current',
'10.1.0' => 'current',
'9.5.0' => 'current',
],
],
[
'currentVersion' => '11.0.0',
'tests' => [
'11.5.0' => 'deprecated',
'11.2.1' => 'deprecated',
'11.0.1' => 'deprecated',
'11.0.0' => 'current',
'10.1.0' => 'current',
'9.5.0' => 'current',
],
],
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
DeprecationHelperTest::deprecatedHelperTestCases | public static | function | |
DeprecationHelperTest::testDeprecationHelper | public | function | @dataProvider deprecatedHelperTestCases |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.