function PercentagesTest::testPercentages

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Batch/PercentagesTest.php \Drupal\Tests\Core\Batch\PercentagesTest::testPercentages()
  2. 10 core/tests/Drupal/Tests/Core/Batch/PercentagesTest.php \Drupal\Tests\Core\Batch\PercentagesTest::testPercentages()
  3. 9 core/tests/Drupal/Tests/Core/Batch/PercentagesTest.php \Drupal\Tests\Core\Batch\PercentagesTest::testPercentages()
  4. 8.9.x core/tests/Drupal/Tests/Core/Batch/PercentagesTest.php \Drupal\Tests\Core\Batch\PercentagesTest::testPercentages()

Tests percentages.

@legacy-covers ::format

Attributes

#[DataProvider('providerTestPercentages')]

File

core/tests/Drupal/Tests/Core/Batch/PercentagesTest.php, line 27

Class

PercentagesTest
Tests the Batch helper object.

Namespace

Drupal\Tests\Core\Batch

Code

public function testPercentages(int $total, int|float $current, string $expected_result) : void {
  $actual_result = Percentage::format($total, $current);
  $this->assertEquals($actual_result, $expected_result, sprintf('The expected the batch api percentage at the state %s/%s is %s%% and got %s%%.', $current, $total, $expected_result, $actual_result));
}

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