Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
44 / 44 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| phpbb_functions_validate_string_test | |
100.00% |
44 / 44 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| setUp | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| test_validate_string | |
100.00% |
42 / 42 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | require_once __DIR__ . '/../../phpBB/includes/functions_user.php'; |
| 15 | require_once __DIR__ . '/validate_data_helper.php'; |
| 16 | |
| 17 | class phpbb_functions_validate_string_test extends phpbb_test_case |
| 18 | { |
| 19 | protected $helper; |
| 20 | |
| 21 | protected function setUp(): void |
| 22 | { |
| 23 | parent::setUp(); |
| 24 | |
| 25 | $this->helper = new phpbb_functions_validate_data_helper($this); |
| 26 | } |
| 27 | |
| 28 | public function test_validate_string() |
| 29 | { |
| 30 | $this->helper->assert_valid_data(array( |
| 31 | 'empty_opt' => array( |
| 32 | array(), |
| 33 | '', |
| 34 | array('string', true), |
| 35 | ), |
| 36 | 'empty' => array( |
| 37 | array(), |
| 38 | '', |
| 39 | array('string'), |
| 40 | ), |
| 41 | 'foo' => array( |
| 42 | array(), |
| 43 | 'foobar', |
| 44 | array('string'), |
| 45 | ), |
| 46 | 'foo_minmax_correct' => array( |
| 47 | array(), |
| 48 | 'foobar', |
| 49 | array('string', false, 2, 6), |
| 50 | ), |
| 51 | 'foo_minmax_short' => array( |
| 52 | array('TOO_SHORT'), |
| 53 | 'foobar', |
| 54 | array('string', false, 7, 9), |
| 55 | ), |
| 56 | 'foo_minmax_long' => array( |
| 57 | array('TOO_LONG'), |
| 58 | 'foobar', |
| 59 | array('string', false, 2, 5), |
| 60 | ), |
| 61 | 'empty_short' => array( |
| 62 | array('TOO_SHORT'), |
| 63 | '', |
| 64 | array('string', false, 1, 6), |
| 65 | ), |
| 66 | 'empty_length_opt' => array( |
| 67 | array(), |
| 68 | '', |
| 69 | array('string', true, 1, 6), |
| 70 | ), |
| 71 | )); |
| 72 | } |
| 73 | } |