function NumberTest::testAlphadecimalToIntReturnsZeroWithNullAndEmptyString

Tests the alphadecimal conversion function keeps backward compatibility.

Many tests and code rely on Number::alphadecimalToInt() returning 0 for degenerate values '' and NULL. We must ensure they are accepted.

@group legacy @covers ::alphadecimalToInt

File

core/tests/Drupal/Tests/Component/Utility/NumberTest.php, line 186

Class

NumberTest
Tests number manipulation utilities.

Namespace

Drupal\Tests\Component\Utility

Code

public function testAlphadecimalToIntReturnsZeroWithNullAndEmptyString() : void {
    $deprecationMessage = 'Passing NULL or an empty string to Drupal\\Component\\Utility\\Number::alphadecimalToInt() is deprecated in drupal:11.2.0 and will be removed in drupal:12.0.0. See https://www.drupal.org/node/3494472';
    $this->expectDeprecation($deprecationMessage);
    $this->assertSame(0, Number::alphadecimalToInt(NULL));
    $this->expectDeprecation($deprecationMessage);
    $this->assertSame(0, Number::alphadecimalToInt(''));
}

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