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
13 require_once 'PHPUnit/Framework.php';
18 require_once './libraries/common.lib.php';
21 * Test formating number and byte.
24 class PMA_formatNumberByteDown_test
extends PHPUnit_Framework_TestCase
28 * temporary variable for globals array
31 protected $tmpGlobals;
34 * temporary variable for session array
37 protected $tmpSession;
40 * storing globals and session
42 public function setUp() {
44 $this->tmpGlobals
= $GLOBALS;
45 $this->tmpSession
= $_SESSION;
50 * recovering globals and session
52 public function tearDown() {
54 $GLOBALS = $this->tmpGlobals
;
55 $_SESSION = $this->tmpSession
;
60 * format number data provider
63 public function formatNumberDataProvider() {
65 array(10, 2, 2, '10,00 '),
66 array(100, 2, 0, '100 '),
67 array(100, 2, 2, '0,10 k'),
68 array(-1000.454, 4, 2, '-1 000,45 '),
69 array(0.00003, 3, 2, '0,03 m'),
70 array(0.003, 3, 3, '0,003 '),
71 array(-0.003, 6, 0, '-3 m'),
72 array(100.98, 0, 2, '100,98')
77 * format number test, globals are defined
78 * @dataProvider formatNumberDataProvider
81 public function testFormatNumber($a, $b, $c, $e) {
82 $this->assertEquals($e, (string)PMA_formatNumber($a, $b, $c, false));
86 * format byte down data provider
89 public function formatByteDownDataProvider() {
91 array(10, 2, 2, array('10', 'B')),
92 array(100, 2, 0, array('0', 'KB')),
93 array(100, 3, 0, array('100', 'B')),
94 array(100, 2, 2, array('0,10', 'KB')),
95 array(1034, 3, 2, array('1,01', 'KB')),
96 array(100233, 3, 3, array('97,884', 'KB')),
97 array(2206451, 1, 2, array('2,10', 'MB'))
102 * format byte test, globals are defined
103 * @dataProvider formatByteDownDataProvider
106 public function testFormatByteDown($a, $b, $c, $e) {
107 $result = PMA_formatByteDown($a, $b, $c);
108 $result[0] = trim($result[0]);
109 $this->assertEquals($e, $result);