aboutsummaryrefslogtreecommitdiffstats
path: root/tests/extension/finder_test.php
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2011-06-09 05:13:26 +0200
committerNils Adermann <naderman@naderman.de>2011-09-29 15:42:33 +0200
commit14f1e581faa3b66e7689c55c1e9c0485c0872b1e (patch)
tree437880dd3c80e47a6205beadb005c7ce27a1a960 /tests/extension/finder_test.php
parent8377418466f861f6b3291ae92a71821f0a0be2d6 (diff)
downloadforums-14f1e581faa3b66e7689c55c1e9c0485c0872b1e.tar
forums-14f1e581faa3b66e7689c55c1e9c0485c0872b1e.tar.gz
forums-14f1e581faa3b66e7689c55c1e9c0485c0872b1e.tar.bz2
forums-14f1e581faa3b66e7689c55c1e9c0485c0872b1e.tar.xz
forums-14f1e581faa3b66e7689c55c1e9c0485c0872b1e.zip
[feature/extension-manager] Extension Manager & Finder
Extensions RFC: http://area51.phpbb.com/phpBB/viewtopic.php?f=84&t=41499 Ticket: http://tracker.phpbb.com/browse/PHPBB3-10323 PHPBB3-10323
Diffstat (limited to 'tests/extension/finder_test.php')
-rw-r--r--tests/extension/finder_test.php133
1 files changed, 133 insertions, 0 deletions
diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php
new file mode 100644
index 0000000000..a1b216face
--- /dev/null
+++ b/tests/extension/finder_test.php
@@ -0,0 +1,133 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../mock/cache.php';
+require_once dirname(__FILE__) . '/../mock/extension_manager.php';
+
+class phpbb_extension_finder_test extends phpbb_test_case
+{
+ protected $extension_manager;
+ protected $finder;
+
+ public function setUp()
+ {
+ $this->extension_manager = new phpbb_mock_extension_manager(array(
+ 'foo' => array(
+ 'ext_name' => 'foo',
+ 'ext_active' => '1',
+ 'ext_path' => dirname(__FILE__) . '/ext/foo/',
+ ),
+ 'bar' => array(
+ 'ext_name' => 'bar',
+ 'ext_active' => '1',
+ 'ext_path' => dirname(__FILE__) . '/ext/bar/',
+ ),
+ ));
+
+ $this->finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/');
+ }
+
+ public function test_suffix_get_classes()
+ {
+ $classes = $this->finder
+ ->default_path('includes/default/')
+ ->suffix('_class')
+ ->default_suffix('')
+ ->get_classes();
+
+ sort($classes);
+ $this->assertEquals(
+ array(
+ 'phpbb_default_implementation',
+ 'phpbb_ext_bar_my_hidden_class',
+ 'phpbb_ext_foo_a_class',
+ 'phpbb_ext_foo_b_class',
+ ),
+ $classes
+ );
+ }
+
+ public function test_directory_get_classes()
+ {
+ $classes = $this->finder
+ ->default_path('includes/default/')
+ ->directory('type')
+ ->default_directory('')
+ ->get_classes();
+
+ sort($classes);
+ $this->assertEquals(
+ array(
+ 'phpbb_default_implementation',
+ 'phpbb_ext_foo_sub_type_alternative',
+ 'phpbb_ext_foo_type_alternative',
+ ),
+ $classes
+ );
+ }
+
+ public function test_absolute_directory_get_classes()
+ {
+ $classes = $this->finder
+ ->directory('/type/')
+ ->get_classes();
+
+ sort($classes);
+ $this->assertEquals(
+ array(
+ 'phpbb_ext_foo_type_alternative',
+ ),
+ $classes
+ );
+ }
+
+ public function test_sub_directory_get_classes()
+ {
+ $classes = $this->finder
+ ->directory('/sub/type')
+ ->get_classes();
+
+ sort($classes);
+ $this->assertEquals(
+ array(
+ 'phpbb_ext_foo_sub_type_alternative',
+ ),
+ $classes
+ );
+ }
+
+ public function test_cached_get_files()
+ {
+ $query = array(
+ 'default_path' => 'includes/foo',
+ 'default_suffix' => false,
+ 'default_directory' => 'bar',
+ 'suffix' => false,
+ 'directory' => false,
+ );
+
+
+ $finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/includes/', new phpbb_mock_cache(array(
+ '_extension_finder' => array(
+ md5(serialize($query)) => array('file_name'),
+ ),
+ )));
+
+ $classes = $finder
+ ->default_path($query['default_path'])
+ ->default_directory($query['default_directory'])
+ ->get_files();
+
+ sort($classes);
+ $this->assertEquals(
+ array('file_name'),
+ $classes
+ );
+ }
+}