Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
8.16% |
12 / 147 |
|
50.00% |
3 / 6 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_event_md_exporter_test | |
8.16% |
12 / 147 |
|
50.00% |
3 / 6 |
57.57 | |
0.00% |
0 / 1 |
| crawl_eventsmd_data | |
0.00% |
0 / 119 |
|
0.00% |
0 / 1 |
2 | |||
| test_crawl_eventsmd | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| crawl_phpbb_eventsmd_data | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| test_crawl_phpbb_eventsmd | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| crawl_template_file_data | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 | |||
| test_crawl_template_file | |
100.00% |
6 / 6 |
|
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 | class phpbb_event_md_exporter_test extends phpbb_test_case |
| 15 | { |
| 16 | static public function crawl_eventsmd_data() |
| 17 | { |
| 18 | return array( |
| 19 | array('normal_events.md.test', null, null, array( |
| 20 | 'acp_bbcodes_actions_append' => array( |
| 21 | 'event' => 'acp_bbcodes_actions_append', |
| 22 | 'files' => array( |
| 23 | 'prosilver' => array(), |
| 24 | 'adm' => array('acp_bbcodes.html'), |
| 25 | ), |
| 26 | 'since' => '3.1.0-a3', |
| 27 | 'deprecated' => '', |
| 28 | 'changed' => array( |
| 29 | '3.1.0-a4' => '', |
| 30 | ), |
| 31 | 'description' => 'desc1' . "\n", |
| 32 | ), |
| 33 | 'acp_bbcodes_actions_prepend' => array( |
| 34 | 'event' => 'acp_bbcodes_actions_prepend', |
| 35 | 'files' => array( |
| 36 | 'prosilver' => array(), |
| 37 | 'adm' => array('acp_bbcodes.html'), |
| 38 | ), |
| 39 | 'since' => '3.1.0-a5', |
| 40 | 'deprecated' => '', |
| 41 | 'changed' => array(), |
| 42 | 'description' => 'desc2' . "\n", |
| 43 | ), |
| 44 | 'acp_bbcodes_actions_prepend2' => array( |
| 45 | 'event' => 'acp_bbcodes_actions_prepend2', |
| 46 | 'files' => array( |
| 47 | 'prosilver' => array(), |
| 48 | 'adm' => array('acp_bbcodes.html'), |
| 49 | ), |
| 50 | 'since' => '3.1.0-a4', |
| 51 | 'deprecated' => '', |
| 52 | 'changed' => array( |
| 53 | '3.1.0-a5' => 'Moved up', |
| 54 | '3.1.0-a6' => 'Moved down', |
| 55 | ), |
| 56 | 'description' => 'desc2' . "\n", |
| 57 | ), |
| 58 | 'acp_bbcodes_actions_prepend2_deprecated' => array( |
| 59 | 'event' => 'acp_bbcodes_actions_prepend2_deprecated', |
| 60 | 'files' => array( |
| 61 | 'prosilver' => array(), |
| 62 | 'adm' => array('acp_bbcodes.html'), |
| 63 | ), |
| 64 | 'since' => '3.1.0-a4', |
| 65 | 'deprecated' => '3.1.0-a6', |
| 66 | 'changed' => array( |
| 67 | '3.1.0-a5' => 'Moved up', |
| 68 | '3.1.0-a6' => 'Moved down', |
| 69 | ), |
| 70 | 'description' => 'desc2' . "\n", |
| 71 | ), |
| 72 | 'acp_bbcodes_actions_prepend_deprecated' => array( |
| 73 | 'event' => 'acp_bbcodes_actions_prepend_deprecated', |
| 74 | 'files' => array( |
| 75 | 'prosilver' => array(), |
| 76 | 'adm' => array('acp_bbcodes.html'), |
| 77 | ), |
| 78 | 'since' => '3.1.0-a5', |
| 79 | 'deprecated' => '3.1.0-a6', |
| 80 | 'changed' => array(), |
| 81 | 'description' => 'desc2' . "\n", |
| 82 | ), |
| 83 | )), |
| 84 | array('normal_events.md.test', '3.1.0-a5', '3.1.0-a5', array( |
| 85 | 'acp_bbcodes_actions_prepend' => array( |
| 86 | 'event' => 'acp_bbcodes_actions_prepend', |
| 87 | 'files' => array( |
| 88 | 'prosilver' => array(), |
| 89 | 'adm' => array('acp_bbcodes.html'), |
| 90 | ), |
| 91 | 'since' => '3.1.0-a5', |
| 92 | 'deprecated' => '', |
| 93 | 'changed' => array(), |
| 94 | 'description' => 'desc2' . "\n", |
| 95 | ), |
| 96 | 'acp_bbcodes_actions_prepend2' => array( |
| 97 | 'event' => 'acp_bbcodes_actions_prepend2', |
| 98 | 'files' => array( |
| 99 | 'prosilver' => array(), |
| 100 | 'adm' => array('acp_bbcodes.html'), |
| 101 | ), |
| 102 | 'since' => '3.1.0-a4', |
| 103 | 'deprecated' => '', |
| 104 | 'changed' => array( |
| 105 | '3.1.0-a5' => 'Moved up', |
| 106 | '3.1.0-a6' => 'Moved down', |
| 107 | ), |
| 108 | 'description' => 'desc2' . "\n", |
| 109 | ), |
| 110 | 'acp_bbcodes_actions_prepend2_deprecated' => array( |
| 111 | 'event' => 'acp_bbcodes_actions_prepend2_deprecated', |
| 112 | 'files' => array( |
| 113 | 'prosilver' => array(), |
| 114 | 'adm' => array('acp_bbcodes.html'), |
| 115 | ), |
| 116 | 'since' => '3.1.0-a4', |
| 117 | 'deprecated' => '3.1.0-a6', |
| 118 | 'changed' => array( |
| 119 | '3.1.0-a5' => 'Moved up', |
| 120 | '3.1.0-a6' => 'Moved down', |
| 121 | ), |
| 122 | 'description' => 'desc2' . "\n", |
| 123 | ), |
| 124 | 'acp_bbcodes_actions_prepend_deprecated' => array( |
| 125 | 'event' => 'acp_bbcodes_actions_prepend_deprecated', |
| 126 | 'files' => array( |
| 127 | 'prosilver' => array(), |
| 128 | 'adm' => array('acp_bbcodes.html'), |
| 129 | ), |
| 130 | 'since' => '3.1.0-a5', |
| 131 | 'deprecated' => '3.1.0-a6', |
| 132 | 'changed' => array(), |
| 133 | 'description' => 'desc2' . "\n", |
| 134 | ), |
| 135 | )), |
| 136 | ); |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * @dataProvider crawl_eventsmd_data |
| 141 | * |
| 142 | * @param string $file |
| 143 | * @param string $min_version |
| 144 | * @param string $max_version |
| 145 | * @param array $events |
| 146 | */ |
| 147 | public function test_crawl_eventsmd($file, $min_version, $max_version, $events) |
| 148 | { |
| 149 | $exporter = new \phpbb\event\md_exporter(__DIR__ . '/fixtures/', null, $min_version, $max_version); |
| 150 | $this->assertSame(count($events), $exporter->crawl_eventsmd($file, 'adm')); |
| 151 | $this->assertEquals($events, $exporter->get_events()); |
| 152 | } |
| 153 | |
| 154 | static public function crawl_phpbb_eventsmd_data() |
| 155 | { |
| 156 | return array( |
| 157 | array('styles'), |
| 158 | array('adm'), |
| 159 | ); |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * @dataProvider crawl_phpbb_eventsmd_data |
| 164 | */ |
| 165 | public function test_crawl_phpbb_eventsmd($filter) |
| 166 | { |
| 167 | global $phpbb_root_path; |
| 168 | $exporter = new \phpbb\event\md_exporter($phpbb_root_path); |
| 169 | $this->assertGreaterThan(0, $exporter->crawl_eventsmd('docs/events.md', $filter)); |
| 170 | } |
| 171 | |
| 172 | static public function crawl_template_file_data() |
| 173 | { |
| 174 | global $phpbb_root_path; |
| 175 | $exporter = new \phpbb\event\md_exporter($phpbb_root_path); |
| 176 | $data_provider = array(); |
| 177 | |
| 178 | $styles = array( |
| 179 | 'adm/style/' => 'adm', |
| 180 | 'styles/prosilver/template/' => 'styles', |
| 181 | ); |
| 182 | foreach ($styles as $path => $filter) |
| 183 | { |
| 184 | $files = $exporter->get_recursive_file_list($phpbb_root_path . $path); |
| 185 | foreach ($files as $file) |
| 186 | { |
| 187 | $data_provider[] = array($filter, $path . $file); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | return $data_provider; |
| 192 | } |
| 193 | |
| 194 | /** |
| 195 | * @dataProvider crawl_template_file_data |
| 196 | */ |
| 197 | public function test_crawl_template_file($filter, $file) |
| 198 | { |
| 199 | global $phpbb_root_path; |
| 200 | $exporter = new \phpbb\event\md_exporter($phpbb_root_path); |
| 201 | $exporter->crawl_eventsmd('docs/events.md', $filter); |
| 202 | $events = $exporter->crawl_file_for_events($file); |
| 203 | |
| 204 | $this->assertGreaterThanOrEqual(0, count($events)); |
| 205 | $this->assertTrue($exporter->validate_events_from_file($file, $events)); |
| 206 | } |
| 207 | } |