function PercentagesTest::testPercentages

Same name in other branches
  1. 8.9.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. 11.x core/tests/Drupal/Tests/Core/Batch/PercentagesTest.php \Drupal\Tests\Core\Batch\PercentagesTest::testPercentages()

@dataProvider providerTestPercentages @covers ::format

File

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

Class

PercentagesTest
@coversDefaultClass \Drupal\Core\Batch\Percentage @group Batch

Namespace

Drupal\Tests\Core\Batch

Code

public function testPercentages($total, $current, $expected_result) {
    $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.