aboutsummaryrefslogtreecommitdiffstats
path: root/tests/event/md_exporter_test.php
blob: 0f9d855caa16a16f024f91848c2150acf79b793d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/

class phpbb_event_md_exporter_test extends phpbb_test_case
{

	static public function crawl_eventsmd_data()
	{
		return array(
			array('styles'),
			array('adm'),
		);
	}

	/**
	* @dataProvider crawl_eventsmd_data
	*/
	public function test_crawl_eventsmd($filter)
	{
		global $phpbb_root_path;
		$exporter = new \phpbb\event\md_exporter($phpbb_root_path);
		$this->assertGreaterThan(0, $exporter->crawl_eventsmd('docs/events.md', $filter));
	}

	static public function crawl_template_file_data()
	{
		global $phpbb_root_path;
		$exporter = new \phpbb\event\md_exporter($phpbb_root_path);
		$data_provider = array();

		$styles = array(
			'adm/style/' => 'adm',
			'styles/prosilver/template/' => 'styles',
			'styles/subsilver2/template/' => 'styles',
		);
		foreach ($styles as $path => $filter)
		{
			$files = $exporter->get_recursive_file_list($phpbb_root_path . $path, $path);
			foreach ($files as $file)
			{
				$data_provider[] = array($filter, $path . $file);
			}
		}

		return $data_provider;
	}

	/**
	 * @dataProvider crawl_template_file_data
	 */
	public function test_crawl_template_file($filter, $file)
	{
		global $phpbb_root_path;
		$exporter = new \phpbb\event\md_exporter($phpbb_root_path);
		$exporter->crawl_eventsmd('docs/events.md', $filter);
		$events = $exporter->crawl_file_for_events($file);

		$this->assertGreaterThanOrEqual(0, sizeof($events));
		$this->assertTrue($exporter->validate_events_from_file($file, $events));
	}
}