diff options
author | Andreas Fischer <bantu@phpbb.com> | 2012-06-11 13:22:11 +0200 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2012-06-11 13:22:11 +0200 |
commit | afd6f86892fbbbe06aa0b1295dba361fab29fd5f (patch) | |
tree | 8670ccaed2ef9882828ed036fa431f73dad9d838 /tests/wrapper | |
parent | [ticket/10931] Add wrapper class for ini_get function. (diff) | |
download | phpbb-afd6f86892fbbbe06aa0b1295dba361fab29fd5f.tar.gz phpbb-afd6f86892fbbbe06aa0b1295dba361fab29fd5f.tar.bz2 phpbb-afd6f86892fbbbe06aa0b1295dba361fab29fd5f.zip |
[ticket/10931] Unit tests for phpbb_php_ini class.
PHPBB3-10931
Diffstat (limited to 'tests/wrapper')
-rw-r--r-- | tests/wrapper/phpbb_php_ini_test.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/wrapper/phpbb_php_ini_test.php b/tests/wrapper/phpbb_php_ini_test.php new file mode 100644 index 0000000000..164966fba4 --- /dev/null +++ b/tests/wrapper/phpbb_php_ini_test.php @@ -0,0 +1,58 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once dirname(__FILE__) . '/../mock/phpbb_php_ini.php'; + +class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case +{ + protected $php_ini; + + public function setUp() + { + $this->php_ini = new phpbb_mock_phpbb_php_ini; + } + + public function test_get_string() + { + $this->assertEquals('phpbb', $this->php_ini->get_string(' phpbb ')); + } + + public function test_get_bool() + { + $this->assertEquals(true, $this->php_ini->get_bool('ON')); + $this->assertEquals(true, $this->php_ini->get_bool('on')); + $this->assertEquals(true, $this->php_ini->get_bool('1')); + + $this->assertEquals(false, $this->php_ini->get_bool('OFF')); + $this->assertEquals(false, $this->php_ini->get_bool('off')); + $this->assertEquals(false, $this->php_ini->get_bool('0')); + $this->assertEquals(false, $this->php_ini->get_bool('')); + } + + public function test_get_int() + { + $this->assertEquals(1234, $this->php_ini->get_int('1234')); + $this->assertEquals(false, $this->php_ini->get_int('phpBB')); + } + + public function test_get_float() + { + $this->assertEquals(1234.0, $this->php_ini->get_float('1234')); + $this->assertEquals(false, $this->php_ini->get_float('phpBB')); + } + + public function test_get_bytes() + { + $this->assertEquals(false, $this->php_ini->get_bytes('phpBB')); + $this->assertEquals(false, $this->php_ini->get_bytes('M')); + $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(1234, $this->php_ini->get_bytes('1234')); + } +} |