diff options
author | Andreas Fischer <bantu@phpbb.com> | 2012-06-11 15:15:08 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2012-06-11 15:15:08 +0200 |
commit | 09fb9a9efe048cef102471d1ce79cdeff932776a (patch) | |
tree | e30fa86085e27771a49a1990f3f74d3649e7efb1 /tests/wrapper | |
parent | e9348b172a5b0661b26a8f3a0fe3368568539edb (diff) | |
download | forums-09fb9a9efe048cef102471d1ce79cdeff932776a.tar forums-09fb9a9efe048cef102471d1ce79cdeff932776a.tar.gz forums-09fb9a9efe048cef102471d1ce79cdeff932776a.tar.bz2 forums-09fb9a9efe048cef102471d1ce79cdeff932776a.tar.xz forums-09fb9a9efe048cef102471d1ce79cdeff932776a.zip |
[ticket/10931] Make sure get_bytes() always returns either an int or a float.
PHPBB3-10931
Diffstat (limited to 'tests/wrapper')
-rw-r--r-- | tests/wrapper/phpbb_php_ini_test.php | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/tests/wrapper/phpbb_php_ini_test.php b/tests/wrapper/phpbb_php_ini_test.php index 5c312300d3..4d8e583eb8 100644 --- a/tests/wrapper/phpbb_php_ini_test.php +++ b/tests/wrapper/phpbb_php_ini_test.php @@ -49,18 +49,35 @@ class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case $this->assertSame(false, $this->php_ini->get_float('phpBB')); } - public function test_get_bytes() + public function test_get_bytes_invalid() { $this->assertSame(false, $this->php_ini->get_bytes('phpBB')); $this->assertSame(false, $this->php_ini->get_bytes('k')); $this->assertSame(false, $this->php_ini->get_bytes('-k')); $this->assertSame(false, $this->php_ini->get_bytes('M')); $this->assertSame(false, $this->php_ini->get_bytes('-M')); - $this->assertEquals(32 * pow(2, 20), $this->php_ini->get_bytes('32m')); - $this->assertEquals(- 32 * pow(2, 20), $this->php_ini->get_bytes('-32m')); - $this->assertEquals(8 * pow(2, 30), $this->php_ini->get_bytes('8G')); - $this->assertEquals(- 8 * pow(2, 30), $this->php_ini->get_bytes('-8G')); - $this->assertEquals(1234, $this->php_ini->get_bytes('1234')); - $this->assertEquals(-12345, $this->php_ini->get_bytes('-12345')); + } + + /** + * @dataProvider get_bytes_data + */ + public function test_get_bytes($expected, $value) + { + $actual = $this->php_ini->get_bytes($value); + + $this->assertTrue(is_float($actual) || is_int($actual)); + $this->assertEquals($expected, $actual); + } + + static public function get_bytes_data() + { + return array( + array(32 * pow(2, 20), '32m'), + array(- 32 * pow(2, 20), '-32m'), + array(8 * pow(2, 30), '8G'), + array(- 8 * pow(2, 30), '-8G'), + array(1234, '1234'), + array(-12345, '-12345'), + ); } } |