From 3487b70cc066f090c55990a9082ed9684d438147 Mon Sep 17 00:00:00 2001 From: Marc Alexander <admin@m-a-styles.de> Date: Mon, 3 Jun 2013 16:06:11 +0200 Subject: [ticket/11579] Use test case helper class and use assert prefix for method PHPBB3-11579 --- tests/functions/validate_data_helper.php | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/functions/validate_data_helper.php (limited to 'tests/functions/validate_data_helper.php') diff --git a/tests/functions/validate_data_helper.php b/tests/functions/validate_data_helper.php new file mode 100644 index 0000000000..b8e8bfded3 --- /dev/null +++ b/tests/functions/validate_data_helper.php @@ -0,0 +1,38 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +class phpbb_functions_validate_data_helper extends PHPUnit_Framework_TestCase +{ + protected $test_case; + + public function __construct($test_case) + { + $this->test_case = $test_case; + } + + /** + * Test provided input data with supplied checks and compare to expected + * results + * + * @param array $expected Array containing the expected results. Either + * an array containing the error message or the an empty + * array if input is correct + * @param array $input Input data with specific array keys that need to + * be matched by the ones in the other 2 params + * @param array $validate_check Array containing validate_data check + * settings, i.e. array('foobar' => array('string')) + */ + public function assert_validate_data($expected, $input, $validate_check) + { + foreach ($input as $key => $data) + { + $this->test_case->assertEquals($expected[$key], validate_data(array($data), array($validate_check[$key]))); + } + } +} -- cgit v1.2.1 From 11678678b810c26376728166cf334550cbc30124 Mon Sep 17 00:00:00 2001 From: Marc Alexander <admin@m-a-styles.de> Date: Mon, 3 Jun 2013 21:30:13 +0200 Subject: [ticket/11579] Rework calls to validate_data_helper PHPBB3-11579 --- tests/functions/validate_data_helper.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'tests/functions/validate_data_helper.php') diff --git a/tests/functions/validate_data_helper.php b/tests/functions/validate_data_helper.php index b8e8bfded3..94ddf60429 100644 --- a/tests/functions/validate_data_helper.php +++ b/tests/functions/validate_data_helper.php @@ -20,19 +20,17 @@ class phpbb_functions_validate_data_helper extends PHPUnit_Framework_TestCase * Test provided input data with supplied checks and compare to expected * results * - * @param array $expected Array containing the expected results. Either - * an array containing the error message or the an empty - * array if input is correct - * @param array $input Input data with specific array keys that need to - * be matched by the ones in the other 2 params - * @param array $validate_check Array containing validate_data check - * settings, i.e. array('foobar' => array('string')) + * @param array $data Array containing one or more subarrays with the + * test data. The first element of a subarray is the + * expected result, the second one is the input, and the + * third is the data that should be passed to the function + * validate_data(). */ - public function assert_validate_data($expected, $input, $validate_check) + public function assert_valid_data($data) { - foreach ($input as $key => $data) + foreach ($data as $key => $test) { - $this->test_case->assertEquals($expected[$key], validate_data(array($data), array($validate_check[$key]))); + $this->test_case->assertEquals($test[0], validate_data(array($test[1]), array($test[2]))); } } } -- cgit v1.2.1 From 6a77ee1f30961f6363818691f91162fa67618872 Mon Sep 17 00:00:00 2001 From: Marc Alexander <admin@m-a-styles.de> Date: Wed, 5 Jun 2013 17:05:10 +0200 Subject: [ticket/11579] Do not extend validate_data_helper PHPBB3-11579 --- tests/functions/validate_data_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functions/validate_data_helper.php') diff --git a/tests/functions/validate_data_helper.php b/tests/functions/validate_data_helper.php index 94ddf60429..b92a3aa5eb 100644 --- a/tests/functions/validate_data_helper.php +++ b/tests/functions/validate_data_helper.php @@ -7,7 +7,7 @@ * */ -class phpbb_functions_validate_data_helper extends PHPUnit_Framework_TestCase +class phpbb_functions_validate_data_helper { protected $test_case; -- cgit v1.2.1