diff options
author | Nils Adermann <naderman@naderman.de> | 2014-06-10 18:40:18 +0200 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2014-06-10 18:40:18 +0200 |
commit | 618b73a3d30874eb82bec2398a1b9d6f2ff3856b (patch) | |
tree | 4f889071d2802d0b26991ad775b06eebcbec22b4 /tests/extension | |
parent | 3c68da275bb68265a3f377e85d4e150b688d77f0 (diff) | |
parent | 9842137028f70a2b48ea4eaaddd710cbcf7dc8d5 (diff) | |
download | forums-618b73a3d30874eb82bec2398a1b9d6f2ff3856b.tar forums-618b73a3d30874eb82bec2398a1b9d6f2ff3856b.tar.gz forums-618b73a3d30874eb82bec2398a1b9d6f2ff3856b.tar.bz2 forums-618b73a3d30874eb82bec2398a1b9d6f2ff3856b.tar.xz forums-618b73a3d30874eb82bec2398a1b9d6f2ff3856b.zip |
Merge branch 'develop-ascraeus' into develop
* develop-ascraeus:
[ticket/12508] Ignore extensions in migration_tips dev tool
[ticket/12508] Fix doc block
[ticket/12508] Add new line to separate the if and foreach better
[ticket/12508] Add a unit test for set_extensions()
[ticket/12508] Only take a list of names for set_extensions()
[ticket/12508] Fix class doc block
[ticket/12508] Move \phpbb\extension\finder to \phpbb\finder
[ticket/12508] Fix usages of the finder
[ticket/12508] Remove extension manager from finder
Diffstat (limited to 'tests/extension')
-rw-r--r-- | tests/extension/finder_test.php | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php index 8cc5146b33..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 @@ -201,7 +244,8 @@ class phpbb_extension_finder_test extends phpbb_test_case public function test_get_classes_create_cache() { $cache = new phpbb_mock_cache; - $finder = new \phpbb\extension\finder($this->extension_manager, new \phpbb\filesystem(), dirname(__FILE__) . '/', $cache, 'php', '_custom_cache_name'); + $finder = new \phpbb\finder(new \phpbb\filesystem(), dirname(__FILE__) . '/', $cache, 'php', '_custom_cache_name'); + $finder->set_extensions(array_keys($this->extension_manager->all_enabled())); $files = $finder->suffix('_class.php')->get_files(); $expected_files = array( @@ -239,8 +283,7 @@ class phpbb_extension_finder_test extends phpbb_test_case 'is_dir' => false, ); - $finder = new \phpbb\extension\finder( - $this->extension_manager, + $finder = new \phpbb\finder( new \phpbb\filesystem(), dirname(__FILE__) . '/', new phpbb_mock_cache(array( @@ -249,6 +292,7 @@ class phpbb_extension_finder_test extends phpbb_test_case ), )) ); + $finder->set_extensions(array_keys($this->extension_manager->all_enabled())); $classes = $finder ->core_path($query['core_path']) |