function DeprecationHelperTest::testDeprecationHelper

Same name in other branches
  1. 11.x core/tests/Drupal/Tests/Component/Utility/DeprecationHelperTest.php \Drupal\Tests\Component\Utility\DeprecationHelperTest::testDeprecationHelper()

@dataProvider deprecatedHelperTestCases

Parameters

string $currentVersion: The core version to test against.

array $tests: Array of versions and their expected result.

File

core/tests/Drupal/Tests/Component/Utility/DeprecationHelperTest.php, line 24

Class

DeprecationHelperTest
@coversDefaultClass \Drupal\Component\Utility\DeprecationHelper @group Utility

Namespace

Drupal\Tests\Component\Utility

Code

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}");
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.