diff options
| author | Nils Adermann <naderman@naderman.de> | 2011-06-09 05:13:26 +0200 |
|---|---|---|
| committer | Nils Adermann <naderman@naderman.de> | 2011-09-29 15:42:33 +0200 |
| commit | 14f1e581faa3b66e7689c55c1e9c0485c0872b1e (patch) | |
| tree | 437880dd3c80e47a6205beadb005c7ce27a1a960 /tests/extension/manager_test.php | |
| parent | 8377418466f861f6b3291ae92a71821f0a0be2d6 (diff) | |
| download | forums-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/manager_test.php')
| -rw-r--r-- | tests/extension/manager_test.php | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php new file mode 100644 index 0000000000..ebd92a728d --- /dev/null +++ b/tests/extension/manager_test.php @@ -0,0 +1,89 @@ +<?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'; + +class phpbb_extension_manager_test extends phpbb_database_test_case +{ + protected $extension_manager; + protected $class_loader; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/extensions.xml'); + } + + protected function setUp() + { + parent::setUp(); + + // disable the regular class loader to replace it with one that loads + // test extensions + global $class_loader; + $class_loader->unregister(); + + $prefix = dirname(__FILE__) . '/'; + $this->class_loader = new phpbb_class_loader($prefix . '../../phpBB/includes/', $prefix . 'ext/'); + $this->class_loader->register(); + + $this->extension_manager = new phpbb_extension_manager( + $this->new_dbal(), + 'phpbb_ext', + $prefix, + '.php', + new phpbb_mock_cache + ); + } + + protected function tearDown() + { + global $class_loader; + $class_loader->register(); + } + + public function test_available() + { + $this->assertEquals(array('bar', 'foo', 'moo'), array_keys($this->extension_manager->all_available())); + } + + public function test_enabled() + { + $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); + } + + public function test_configured() + { + $this->assertEquals(array('foo', 'moo'), array_keys($this->extension_manager->all_configured())); + } + + public function test_enable() + { + $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); + $this->extension_manager->enable('bar'); + $this->assertEquals(array('bar', 'foo'), array_keys($this->extension_manager->all_enabled())); + $this->assertEquals(array('bar', 'foo', 'moo'), array_keys($this->extension_manager->all_configured())); + } + + public function test_disable() + { + $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); + $this->extension_manager->disable('foo'); + $this->assertEquals(array(), array_keys($this->extension_manager->all_enabled())); + $this->assertEquals(array('foo', 'moo'), array_keys($this->extension_manager->all_configured())); + } + + public function test_purge() + { + $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); + $this->assertEquals(array('foo', 'moo'), array_keys($this->extension_manager->all_configured())); + $this->extension_manager->purge('moo'); + $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); + $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_configured())); + } +} |
