From fb3c6b94aeaf77b40e815c65e0982f38aebd7384 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 9 May 2014 09:41:49 +0200 Subject: [ticket/12508] Add a unit test for set_extensions() PHPBB3-12508 --- tests/extension/finder_test.php | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'tests/extension/finder_test.php') diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php index 5ff4c59722..2116cc057b 100644 --- a/tests/extension/finder_test.php +++ b/tests/extension/finder_test.php @@ -14,7 +14,9 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_extension_finder_test extends phpbb_test_case { + /** @var \phpbb\extension\manager */ protected $extension_manager; + /** @var \phpbb\finder */ protected $finder; public function setUp() @@ -56,6 +58,47 @@ class phpbb_extension_finder_test extends phpbb_test_case ); } + public function set_extensions_data() + { + return array( + array( + array(), + array('\phpbb\default\implementation'), + ), + array( + array('vendor3/bar'), + array( + '\phpbb\default\implementation', + '\vendor3\bar\my\hidden_class', + ), + ), + array( + array('vendor2/foo', 'vendor3/bar'), + array( + '\phpbb\default\implementation', + '\vendor2\foo\a_class', + '\vendor2\foo\b_class', + '\vendor3\bar\my\hidden_class', + ), + ), + ); + } + + /** + * @dataProvider set_extensions_data + */ + public function test_set_extensions($extensions, $expected) + { + $classes = $this->finder + ->set_extensions($extensions) + ->core_path('phpbb/default/') + ->extension_suffix('_class') + ->get_classes(); + + sort($classes); + $this->assertEquals($expected, $classes); + } + public function test_get_directories() { $dirs = $this->finder -- cgit v1.2.1