From 9a52bd030189280f48a35d3b9e52f9d77071cb5e Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 3 Jan 2011 22:21:54 +0100 Subject: [task/phpunit-xml] Use phpunit.xml for test suite PHPBB3-9967 --- tests/request/all_tests.php | 41 ----------------------------------------- tests/request/request_var.php | 3 +-- 2 files changed, 1 insertion(+), 43 deletions(-) delete mode 100644 tests/request/all_tests.php (limited to 'tests/request') diff --git a/tests/request/all_tests.php b/tests/request/all_tests.php deleted file mode 100644 index 1ee3029b36..0000000000 --- a/tests/request/all_tests.php +++ /dev/null @@ -1,41 +0,0 @@ -addTestSuite('phpbb_request_request_var_test'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'phpbb_request_all_tests::main') -{ - phpbb_request_all_tests::main(); -} - diff --git a/tests/request/request_var.php b/tests/request/request_var.php index b1dacef3fd..804e5d6390 100644 --- a/tests/request/request_var.php +++ b/tests/request/request_var.php @@ -7,8 +7,7 @@ * */ -require_once 'test_framework/framework.php'; -require_once '../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions.php'; class phpbb_request_request_var_test extends phpbb_test_case { -- cgit v1.2.1 From 69616db1ed2ed21db14e2253851a9d76998072d0 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 7 Jan 2011 22:45:39 +0100 Subject: [ticket/9981] Fix unit test dependencies PHPBB3-9981 --- tests/request/request_var.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/request') diff --git a/tests/request/request_var.php b/tests/request/request_var.php index 804e5d6390..0901b43920 100644 --- a/tests/request/request_var.php +++ b/tests/request/request_var.php @@ -8,6 +8,7 @@ */ require_once __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_request_request_var_test extends phpbb_test_case { -- cgit v1.2.1 From 01fe91c5c4e897801f5c179cd4060e686762f105 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 10 Jan 2011 00:18:37 +0100 Subject: [ticket/9987] Rename test files to include a _test suffix PHPBB3-9987 --- tests/request/request_var.php | 180 ------------------------------------- tests/request/request_var_test.php | 180 +++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+), 180 deletions(-) delete mode 100644 tests/request/request_var.php create mode 100644 tests/request/request_var_test.php (limited to 'tests/request') diff --git a/tests/request/request_var.php b/tests/request/request_var.php deleted file mode 100644 index 0901b43920..0000000000 --- a/tests/request/request_var.php +++ /dev/null @@ -1,180 +0,0 @@ -unset_variables($variable_name); - - $_POST[$variable_name] = $variable_value; - $_REQUEST[$variable_name] = $variable_value; - - $result = request_var($variable_name, $default, $multibyte); - - $label = 'Requesting POST variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : ''); - $this->assertEquals($expected, $result, $label); - } - - /** - * @dataProvider request_variables - */ - public function test_get($variable_value, $default, $multibyte, $expected) - { - $variable_name = 'name'; - $this->unset_variables($variable_name); - - $_GET[$variable_name] = $variable_value; - $_REQUEST[$variable_name] = $variable_value; - - $result = request_var($variable_name, $default, $multibyte); - - $label = 'Requesting GET variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : ''); - $this->assertEquals($expected, $result, $label); - } - - /** - * @dataProvider request_variables - */ - public function test_cookie($variable_value, $default, $multibyte, $expected) - { - $variable_name = 'name'; - $this->unset_variables($variable_name); - - $_GET[$variable_name] = false; - $_POST[$variable_name] = false; - $_REQUEST[$variable_name] = false; - $_COOKIE[$variable_name] = $variable_value; - - $result = request_var($variable_name, $default, $multibyte, true); - - $label = 'Requesting COOKIE variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : ''); - $this->assertEquals($expected, $result, $label); - } - - /** - * Helper for unsetting globals - */ - private function unset_variables($var) - { - unset($_GET[$var], $_POST[$var], $_REQUEST[$var], $_COOKIE[$var]); - } - - public static function request_variables() - { - return array( - // strings - array('abc', '', false, 'abc'), - array(' some spaces ', '', true, 'some spaces'), - array("\r\rsome\rcarriage\r\rreturns\r", '', true, "some\ncarriage\n\nreturns"), - array("\n\nsome\ncarriage\n\nreturns\n", '', true, "some\ncarriage\n\nreturns"), - array("\r\n\r\nsome\r\ncarriage\r\n\r\nreturns\r\n", '', true, "some\ncarriage\n\nreturns"), - array("we\xC2\xA1rd\xE1\x9A\x80ch\xCE\xB1r\xC2\xADacters", '', true, "we\xC2\xA1rd\xE1\x9A\x80ch\xCE\xB1r\xC2\xADacters"), - array("we\xC2\xA1rd\xE1\x9A\x80ch\xCE\xB1r\xC2\xADacters", '', false, "we??rd???ch??r??acters"), - array("Some \"entities\" like &", '', true, "Some <html> "entities" like &"), - - // integers - array('1234', 0, false, 1234), - array('abc', 12, false, 0), - array('324abc', 0, false, 324), - - // string to array - array('123', array(0), false, array()), - array('123', array(''), false, array()), - - // 1 dimensional arrays - array( - // input: - array('123', 'abc'), - // default: - array(''), - false, - // expected: - array('123', 'abc') - ), - array( - // input: - array('123', 'abc'), - // default: - array(999), - false, - // expected: - array(123, 0) - ), - array( - // input: - array('xyz' => '123', 'abc' => 'abc'), - // default: - array('' => ''), - false, - // expected: - array('xyz' => '123', 'abc' => 'abc') - ), - array( - // input: - array('xyz' => '123', 'abc' => 'abc'), - // default: - array('' => 0), - false, - // expected: - array('xyz' => 123, 'abc' => 0) - ), - - // 2 dimensional arrays - array( - // input: - '', - // default: - array(array(0)), - false, - // expected: - array() - ), - array( - // input: - array( - 'xyz' => array('123', 'def'), - 'abc' => 'abc' - ), - // default: - array('' => array('')), - false, - // expected: - array( - 'xyz' => array('123', 'def'), - 'abc' => array() - ) - ), - array( - // input: - array( - 'xyz' => array('123', 'def'), - 'abc' => 'abc' - ), - // default: - array('' => array(0)), - false, - // expected: - array( - 'xyz' => array(123, 0), - 'abc' => array() - ) - ), - ); - } - -} - diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php new file mode 100644 index 0000000000..0901b43920 --- /dev/null +++ b/tests/request/request_var_test.php @@ -0,0 +1,180 @@ +unset_variables($variable_name); + + $_POST[$variable_name] = $variable_value; + $_REQUEST[$variable_name] = $variable_value; + + $result = request_var($variable_name, $default, $multibyte); + + $label = 'Requesting POST variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : ''); + $this->assertEquals($expected, $result, $label); + } + + /** + * @dataProvider request_variables + */ + public function test_get($variable_value, $default, $multibyte, $expected) + { + $variable_name = 'name'; + $this->unset_variables($variable_name); + + $_GET[$variable_name] = $variable_value; + $_REQUEST[$variable_name] = $variable_value; + + $result = request_var($variable_name, $default, $multibyte); + + $label = 'Requesting GET variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : ''); + $this->assertEquals($expected, $result, $label); + } + + /** + * @dataProvider request_variables + */ + public function test_cookie($variable_value, $default, $multibyte, $expected) + { + $variable_name = 'name'; + $this->unset_variables($variable_name); + + $_GET[$variable_name] = false; + $_POST[$variable_name] = false; + $_REQUEST[$variable_name] = false; + $_COOKIE[$variable_name] = $variable_value; + + $result = request_var($variable_name, $default, $multibyte, true); + + $label = 'Requesting COOKIE variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : ''); + $this->assertEquals($expected, $result, $label); + } + + /** + * Helper for unsetting globals + */ + private function unset_variables($var) + { + unset($_GET[$var], $_POST[$var], $_REQUEST[$var], $_COOKIE[$var]); + } + + public static function request_variables() + { + return array( + // strings + array('abc', '', false, 'abc'), + array(' some spaces ', '', true, 'some spaces'), + array("\r\rsome\rcarriage\r\rreturns\r", '', true, "some\ncarriage\n\nreturns"), + array("\n\nsome\ncarriage\n\nreturns\n", '', true, "some\ncarriage\n\nreturns"), + array("\r\n\r\nsome\r\ncarriage\r\n\r\nreturns\r\n", '', true, "some\ncarriage\n\nreturns"), + array("we\xC2\xA1rd\xE1\x9A\x80ch\xCE\xB1r\xC2\xADacters", '', true, "we\xC2\xA1rd\xE1\x9A\x80ch\xCE\xB1r\xC2\xADacters"), + array("we\xC2\xA1rd\xE1\x9A\x80ch\xCE\xB1r\xC2\xADacters", '', false, "we??rd???ch??r??acters"), + array("Some \"entities\" like &", '', true, "Some <html> "entities" like &"), + + // integers + array('1234', 0, false, 1234), + array('abc', 12, false, 0), + array('324abc', 0, false, 324), + + // string to array + array('123', array(0), false, array()), + array('123', array(''), false, array()), + + // 1 dimensional arrays + array( + // input: + array('123', 'abc'), + // default: + array(''), + false, + // expected: + array('123', 'abc') + ), + array( + // input: + array('123', 'abc'), + // default: + array(999), + false, + // expected: + array(123, 0) + ), + array( + // input: + array('xyz' => '123', 'abc' => 'abc'), + // default: + array('' => ''), + false, + // expected: + array('xyz' => '123', 'abc' => 'abc') + ), + array( + // input: + array('xyz' => '123', 'abc' => 'abc'), + // default: + array('' => 0), + false, + // expected: + array('xyz' => 123, 'abc' => 0) + ), + + // 2 dimensional arrays + array( + // input: + '', + // default: + array(array(0)), + false, + // expected: + array() + ), + array( + // input: + array( + 'xyz' => array('123', 'def'), + 'abc' => 'abc' + ), + // default: + array('' => array('')), + false, + // expected: + array( + 'xyz' => array('123', 'def'), + 'abc' => array() + ) + ), + array( + // input: + array( + 'xyz' => array('123', 'def'), + 'abc' => 'abc' + ), + // default: + array('' => array(0)), + false, + // expected: + array( + 'xyz' => array(123, 0), + 'abc' => array() + ) + ), + ); + } + +} + -- cgit v1.2.1 From 14891cdf4ecf0e3ee164962be6685b8563f37a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Fr=C3=A8rejean?= Date: Mon, 31 Jan 2011 12:58:18 +0100 Subject: [ticket/10011] Tests don't work on PHP < 5.3 Due to the usage of `__DIR__` for the file includes the tests can't be ran on systems with PHP < 5.3. Replace all occurances of `__DIR__` with `dirname(__FILE__)`. PHPBB3-10011 --- tests/request/request_var_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/request') diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php index 0901b43920..fa17b1909f 100644 --- a/tests/request/request_var_test.php +++ b/tests/request/request_var_test.php @@ -7,8 +7,8 @@ * */ -require_once __DIR__ . '/../../phpBB/includes/functions.php'; -require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_request_request_var_test extends phpbb_test_case { -- cgit v1.2.1