Advisor: mark that 'Rate of reading fixed position' may be wrong, requires further...
[phpmyadmin/thilanka.git] / test / libraries / common / PMA_formatNumberByteDown_test.php
blob18ab8ba96ddf60370a80b9af6030abadd404822b
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for format number and byte
6 * @package phpMyAdmin-test
7 * @version $Id: PMA_formatNumberByteDown_test.php
8 * @group common.lib-tests
9 */
12 * Include to test.
14 require_once 'libraries/common.lib.php';
16 class PMA_formatNumberByteDown_test extends PHPUnit_Framework_TestCase
18 /**
19 * temporary variable for globals array
21 protected $tmpGlobals;
23 /**
24 * temporary variable for session array
26 protected $tmpSession;
28 /**
29 * storing globals and session
31 public function setUp() {
33 $this->tmpGlobals = $GLOBALS;
34 $this->tmpSession = $_SESSION;
38 /**
39 * recovering globals and session
41 public function tearDown() {
43 $GLOBALS = $this->tmpGlobals;
44 $_SESSION = $this->tmpSession;
48 /**
49 * format number data provider
51 * @return array
53 public function formatNumberDataProvider() {
54 return array(
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 &micro;'),
60 array(0.003, 3, 3, '3 m'),
61 array(-0.003, 6, 0, '-3,000 &micro;'),
62 array(100.98, 0, 2, '100.98')
66 /**
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));
74 /**
75 * format byte down data provider
77 * @return array
79 public function formatByteDownDataProvider() {
80 return array(
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')))
91 /**
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);