-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for vipgoci_round_array_items()
- Loading branch information
1 parent
e9a704c
commit 78f1ba2
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Vipgoci\tests; | ||
|
||
require_once( __DIR__ . '/IncludesForTests.php' ); | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
// phpcs:disable PSR1.Files.SideEffects | ||
|
||
final class MiscRoundArrayItemsTest extends TestCase { | ||
/** | ||
* @covers ::vipgoci_round_array_items | ||
*/ | ||
public function testRoundArrayItems() { | ||
$org_array = array( | ||
'test1' => 10.333330, | ||
'test2' => 0.034444444, | ||
'test3' => 3.359999999, | ||
'test4' => 5.0000003, | ||
'test5' => 7.377777777, | ||
'test6' => 5.00000001, | ||
); | ||
|
||
$res_array = vipgoci_round_array_items( | ||
$org_array, | ||
2, | ||
PHP_ROUND_HALF_UP | ||
); | ||
|
||
$expected_array = array( | ||
'test1' => 10.33, | ||
'test2' => 0.03, | ||
'test3' => 3.36, | ||
'test4' => 5.00, | ||
'test5' => 7.38, | ||
'test6' => 5.0, | ||
); | ||
|
||
$this->assertSame( | ||
$expected_array, | ||
$res_array | ||
); | ||
} | ||
} |