mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 14:00:31 +02:00
[ticket/11579] Use test case helper class and use assert prefix for method
PHPBB3-11579
This commit is contained in:
38
tests/functions/validate_data_helper.php
Normal file
38
tests/functions/validate_data_helper.php
Normal file
@@ -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])));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user