2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for format number and byte
6 * @package phpMyAdmin-test
7 * @version $Id: PMA_formatNumberByteDown_test.php
8 * @group common.lib-tests
14 require_once 'libraries/common.lib.php';
16 class PMA_formatNumberByteDown_test
extends PHPUnit_Framework_TestCase
19 * temporary variable for globals array
21 protected $tmpGlobals;
24 * temporary variable for session array
26 protected $tmpSession;
29 * storing globals and session
31 public function setUp() {
33 $this->tmpGlobals
= $GLOBALS;
34 $this->tmpSession
= $_SESSION;
39 * recovering globals and session
41 public function tearDown() {
43 $GLOBALS = $this->tmpGlobals
;
44 $_SESSION = $this->tmpSession
;
49 * format number data provider
53 public function formatNumberDataProvider() {
55 array(10, 2, 2, '10 '),
56 array(100, 2, 0, '100 '),
57 array(100, 2, 2, '100 '),
58 array(-1000.454, 4, 2, '-1,000.45 '),
59 array(0.00003, 3, 2, '30 µ'),
60 array(0.003, 3, 3, '3 m'),
61 array(-0.003, 6, 0, '-3,000 µ'),
62 array(100.98, 0, 2, '100.98')
67 * format number test, globals are defined
68 * @dataProvider formatNumberDataProvider
70 public function testFormatNumber($a, $b, $c, $d) {
71 $this->assertEquals($d, (string)PMA_formatNumber($a, $b, $c, false));
75 * format byte down data provider
79 public function formatByteDownDataProvider() {
81 array(10, 2, 2, array('10', __('B'))),
82 array(100, 2, 0, array('0', __('KiB'))),
83 array(100, 3, 0, array('100', __('B'))),
84 array(100, 2, 2, array('0.10', __('KiB'))),
85 array(1034, 3, 2, array('1.01', __('KiB'))),
86 array(100233, 3, 3, array('97.884', __('KiB'))),
87 array(2206451, 1, 2, array('2.10', __('MiB')))
92 * format byte test, globals are defined
93 * @dataProvider formatByteDownDataProvider
95 public function testFormatByteDown($a, $b, $c, $e) {
96 $result = PMA_formatByteDown($a, $b, $c);
97 $result[0] = trim($result[0]);
98 $this->assertEquals($e, $result);