Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
67.27% |
37 / 55 |
|
44.00% |
11 / 25 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_mock_cache | |
67.27% |
37 / 55 |
|
44.00% |
11 / 25 |
64.69 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| put | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| obtain_word_list | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
1 | |||
| obtain_disallowed_usernames | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| checkVar | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| checkAssociativeVar | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |||
| checkVarUnset | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| check | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
2 | |||
| load | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| unload | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| save | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| tidy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| purge | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| destroy | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| _exists | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sql_load | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sql_save | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sql_exists | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| sql_fetchrow | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sql_fetchfield | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sql_rowseek | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sql_freeresult | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| obtain_bots | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| clean_query_id | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 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 | class phpbb_mock_cache implements \phpbb\cache\driver\driver_interface |
| 15 | { |
| 16 | protected $data; |
| 17 | |
| 18 | public function __construct($data = array()) |
| 19 | { |
| 20 | $this->data = $data; |
| 21 | } |
| 22 | |
| 23 | public function get($var_name) |
| 24 | { |
| 25 | if (isset($this->data[$var_name])) |
| 26 | { |
| 27 | return $this->data[$var_name]; |
| 28 | } |
| 29 | |
| 30 | return false; |
| 31 | } |
| 32 | |
| 33 | public function put($var_name, $var, $ttl = 0) |
| 34 | { |
| 35 | $this->data[$var_name] = $var; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Obtain list of word censors. We don't need to parse them here, |
| 40 | * that is tested elsewhere. |
| 41 | */ |
| 42 | public function obtain_word_list() |
| 43 | { |
| 44 | return array( |
| 45 | 'match' => array( |
| 46 | '#(?<![\\p{Nd}\\p{L}_-])([\\p{Nd}\\p{L}_-]*?badword1[\\p{Nd}\\p{L}_-]*?)(?![\\p{Nd}\\p{L}_-])#iu', |
| 47 | '#(?<![\\p{Nd}\\p{L}_-])([\\p{Nd}\\p{L}_-]*?badword2)(?![\\p{Nd}\\p{L}_-])#iu', |
| 48 | '#(?<![\\p{Nd}\\p{L}_-])(badword3[\\p{Nd}\\p{L}_-]*?)(?![\\p{Nd}\\p{L}_-])#iu', |
| 49 | '#(?<![\\p{Nd}\\p{L}_-])(badword4)(?![\\p{Nd}\\p{L}_-])#iu', |
| 50 | ), |
| 51 | 'replace' => array( |
| 52 | 'replacement1', |
| 53 | 'replacement2', |
| 54 | 'replacement3', |
| 55 | 'replacement4', |
| 56 | ), |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Obtain disallowed usernames. Input data via standard put method. |
| 62 | */ |
| 63 | public function obtain_disallowed_usernames() |
| 64 | { |
| 65 | if (($usernames = $this->get('_disallowed_usernames')) !== false) |
| 66 | { |
| 67 | return $usernames; |
| 68 | } |
| 69 | else |
| 70 | { |
| 71 | return array(); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | public function checkVar(PHPUnit\Framework\Assert $test, $var_name, $data) |
| 76 | { |
| 77 | $test->assertTrue(isset($this->data[$var_name])); |
| 78 | $test->assertEquals($data, $this->data[$var_name]); |
| 79 | } |
| 80 | |
| 81 | public function checkAssociativeVar(PHPUnit\Framework\Assert $test, $var_name, $data, $sort = true) |
| 82 | { |
| 83 | $test->assertTrue(isset($this->data[$var_name])); |
| 84 | |
| 85 | if ($sort) |
| 86 | { |
| 87 | foreach ($this->data[$var_name] as &$content) |
| 88 | { |
| 89 | sort($content); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | $test->assertEquals($data, $this->data[$var_name]); |
| 94 | } |
| 95 | |
| 96 | public function checkVarUnset(PHPUnit\Framework\Assert $test, $var_name) |
| 97 | { |
| 98 | $test->assertFalse(isset($this->data[$var_name])); |
| 99 | } |
| 100 | |
| 101 | public function check(PHPUnit\Framework\Assert $test, $data, $ignore_db_info = true) |
| 102 | { |
| 103 | $cache_data = $this->data; |
| 104 | |
| 105 | if ($ignore_db_info) |
| 106 | { |
| 107 | unset($cache_data['mssqlodbc_version']); |
| 108 | unset($cache_data['mssql_version']); |
| 109 | unset($cache_data['mysql_version']); |
| 110 | unset($cache_data['mysqli_version']); |
| 111 | unset($cache_data['pgsql_version']); |
| 112 | unset($cache_data['sqlite_version']); |
| 113 | } |
| 114 | |
| 115 | $test->assertEquals($data, $cache_data); |
| 116 | } |
| 117 | |
| 118 | function load() |
| 119 | { |
| 120 | } |
| 121 | function unload() |
| 122 | { |
| 123 | } |
| 124 | function save() |
| 125 | { |
| 126 | } |
| 127 | function tidy() |
| 128 | { |
| 129 | } |
| 130 | function purge() |
| 131 | { |
| 132 | } |
| 133 | function destroy($var_name, $table = '') |
| 134 | { |
| 135 | unset($this->data[$var_name]); |
| 136 | } |
| 137 | public function _exists($var_name) |
| 138 | { |
| 139 | } |
| 140 | public function sql_load($query) |
| 141 | { |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * {@inheritDoc} |
| 146 | */ |
| 147 | public function sql_save(\phpbb\db\driver\driver_interface $db, $query, $query_result, $ttl) |
| 148 | { |
| 149 | return $query_result; |
| 150 | } |
| 151 | public function sql_exists($query_id) |
| 152 | { |
| 153 | } |
| 154 | public function sql_fetchrow($query_id) |
| 155 | { |
| 156 | } |
| 157 | public function sql_fetchfield($query_id, $field) |
| 158 | { |
| 159 | } |
| 160 | public function sql_rowseek($rownum, $query_id) |
| 161 | { |
| 162 | } |
| 163 | public function sql_freeresult($query_id) |
| 164 | { |
| 165 | } |
| 166 | |
| 167 | public function obtain_bots() |
| 168 | { |
| 169 | return isset($this->data['_bots']) ? $this->data['_bots'] : array(); |
| 170 | } |
| 171 | |
| 172 | public function clean_query_id($query_id) |
| 173 | { |
| 174 | } |
| 175 | } |