diff options
author | Marc Alexander <admin@m-a-styles.de> | 2013-06-03 16:06:11 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2013-06-03 16:06:11 +0200 |
commit | 3487b70cc066f090c55990a9082ed9684d438147 (patch) | |
tree | 850fbd6caacdc29c3632cdf4ce76413f69498684 /tests/functions/validate_data_helper.php | |
parent | 33a0859f4ac3454c12dda651f708e16fc6c45adb (diff) | |
download | forums-3487b70cc066f090c55990a9082ed9684d438147.tar forums-3487b70cc066f090c55990a9082ed9684d438147.tar.gz forums-3487b70cc066f090c55990a9082ed9684d438147.tar.bz2 forums-3487b70cc066f090c55990a9082ed9684d438147.tar.xz forums-3487b70cc066f090c55990a9082ed9684d438147.zip |
[ticket/11579] Use test case helper class and use assert prefix for method
PHPBB3-11579
Diffstat (limited to 'tests/functions/validate_data_helper.php')
-rw-r--r-- | tests/functions/validate_data_helper.php | 38 |
1 files changed, 38 insertions, 0 deletions
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]))); + } + } +} |