function LegacyCommonTest::testFormatSizeDeprecation

Same name and namespace in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Common/LegacyCommonTest.php \Drupal\KernelTests\Core\Common\LegacyCommonTest::testFormatSizeDeprecation()

Tests deprecation of the format_size() function.

File

core/tests/Drupal/KernelTests/Core/Common/LegacyCommonTest.php, line 18

Class

LegacyCommonTest
Tests deprecated legacy functions in <a href="/api/drupal/core%21includes%21common.inc/11.x" title="Common functions that many Drupal modules will need to reference." class="local">common.inc</a>.

Namespace

Drupal\KernelTests\Core\Common

Code

public function testFormatSizeDeprecation() : void {
    $this->expectDeprecation('format_size() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use \\Drupal\\Core\\StringTranslation\\ByteSizeMarkup::create($size, $langcode) instead. See https://www.drupal.org/node/2999981');
    $size = format_size(4053371676);
    $this->assertEquals('3.77 GB', $size);
    $this->assertEquals('@size GB', $size->getUntranslatedString());
}

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