diff --git a/core/lib/Drupal/Component/Batch/Batch.php b/core/lib/Drupal/Component/Batch/Batch.php index 7d863cb..dd718a1 100644 --- a/core/lib/Drupal/Component/Batch/Batch.php +++ b/core/lib/Drupal/Component/Batch/Batch.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Component\Batch\Batch. + * Contains \Drupal\Component\Batch\Batch. */ namespace Drupal\Component\Batch; @@ -11,18 +11,19 @@ * Helper methods for the batch system. */ class Batch { + /** * Formats the percent completion for a batch set. * - * @param $total + * @param int $total * The total number of operations. - * @param $current + * @param int $current * The number of the current operation. This may be a floating point number * rather than an integer in the case of a multi-step operation that is not * yet complete; in that case, the fractional part of $current represents the * fraction of the operation that has been completed. * - * @return + * @return string * The properly formatted percentage, as a string. We output percentages * using the correct number of decimal places so that we never print "100%" * until we are finished, but we also never print more decimal places than @@ -34,7 +35,7 @@ public static function percentage($total, $current) { if (!$total || $total == $current) { // If $total doesn't evaluate as true or is equal to the current set, then // we're finished, and we can return "100". - $percentage = "100"; + $percentage = '100'; } else { // We add a new digit at 200, 2000, etc. (since, for example, 199/200 @@ -53,4 +54,5 @@ public static function percentage($total, $current) { } return $percentage; } + } diff --git a/core/tests/Drupal/Tests/Component/Batch/PercentagesTest.php b/core/tests/Drupal/Tests/Component/Batch/PercentagesTest.php index d533ee3..4c19d0f 100644 --- a/core/tests/Drupal/Tests/Component/Batch/PercentagesTest.php +++ b/core/tests/Drupal/Tests/Component/Batch/PercentagesTest.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\system\Tests\Batch\PercentagesTest. + * Contains \Drupal\system\Tests\Batch\PercentagesTest. */ namespace Drupal\Tests\Component\Batch; @@ -13,10 +13,12 @@ /** * Unit tests of progress percentage rounding. * - * Tests the function _batch_api_percentage() to make sure that the rounding - * works properly in all cases. + * Tests the Batch helper object to make sure that the rounding works properly + * in all cases. + * + * @see \Drupal\Component\Batch\Batch */ -class PercentagesTest extends UnitTestCase { +class BatchTest extends UnitTestCase { protected $testCases = array(); public static function getInfo() { @@ -28,17 +30,21 @@ public static function getInfo() { } /** - * Tests the _batch_api_percentage() function. + * Tests the percentage() function. * * @dataProvider provider + * + * @see \Drupal\Component\Batch\Batch::percentage() */ - function testBatchPercentages($total, $current, $expected_result) { + public function testPercentages($total, $current, $expected_result) { $actual_result = Batch::percentage($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)); } - /** * Provide data for batch unit tests. + * + * @return array + * An array of data used by the test. */ public function provider() { // Set up an array of test cases. @@ -90,4 +96,5 @@ public function provider() { array('total' => 1, 'current' => 500/501, '99.8'), ); } + } diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php index c03d125..67eea28 100644 --- a/core/tests/Drupal/Tests/UnitTestCase.php +++ b/core/tests/Drupal/Tests/UnitTestCase.php @@ -7,7 +7,7 @@ namespace Drupal\Tests; -class UnitTestCase extends \PHPUnit_Framework_TestCase { +abstract class UnitTestCase extends \PHPUnit_Framework_TestCase { /** * This method exists to support the simpletest UI runner.