diff options
| author | Marc Alexander <admin@m-a-styles.de> | 2013-02-07 00:07:59 +0100 |
|---|---|---|
| committer | Marc Alexander <admin@m-a-styles.de> | 2013-02-07 00:07:59 +0100 |
| commit | c56db535b4f0c943777ab159c14729d724f5d232 (patch) | |
| tree | 56a63ae78f97a990d3ca1512c5333aebd467895a /tests/dbal/migrator_tool_module.php | |
| parent | 11aff559d4fcde5c2935aa6ebdfcfbe162d91f64 (diff) | |
| parent | effaef6bddf49b9016d66bd64706392fcdb452b3 (diff) | |
| download | forums-c56db535b4f0c943777ab159c14729d724f5d232.tar forums-c56db535b4f0c943777ab159c14729d724f5d232.tar.gz forums-c56db535b4f0c943777ab159c14729d724f5d232.tar.bz2 forums-c56db535b4f0c943777ab159c14729d724f5d232.tar.xz forums-c56db535b4f0c943777ab159c14729d724f5d232.zip | |
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into feature/avatars
Conflicts:
phpBB/config/services.yml
Diffstat (limited to 'tests/dbal/migrator_tool_module.php')
| -rw-r--r-- | tests/dbal/migrator_tool_module.php | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/tests/dbal/migrator_tool_module.php b/tests/dbal/migrator_tool_module.php new file mode 100644 index 0000000000..6937b6f8c5 --- /dev/null +++ b/tests/dbal/migrator_tool_module.php @@ -0,0 +1,150 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/tool/module.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/db/migration/exception.php'; + +class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case +{ + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_module.xml'); + } + + public function setup() + { + // Need global $db, $user for delete_module function in acp_modules + global $phpbb_root_path, $phpEx, $skip_add_log, $db, $user; + + parent::setup(); + + // Force add_log function to not be used + $skip_add_log = true; + + $db = $this->db = $this->new_dbal(); + $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null(), new phpbb_config(array()), $this->db, $phpbb_root_path, $phpEx); + $user = $this->user = new phpbb_user(); + + $this->tool = new phpbb_db_migration_tool_module($this->db, $this->cache, $this->user, $phpbb_root_path, $phpEx, 'phpbb_modules'); + } + + public function exists_data() + { + return array( + // Test the category + array( + '', + 'ACP_CAT', + true, + ), + array( + 0, + 'ACP_CAT', + true, + ), + + // Test the module + array( + '', + 'ACP_MODULE', + false, + ), + array( + false, + 'ACP_MODULE', + true, + ), + array( + 'ACP_CAT', + 'ACP_MODULE', + true, + ), + ); + } + + /** + * @dataProvider exists_data + */ + public function test_exists($parent, $module, $expected) + { + $this->assertEquals($expected, $this->tool->exists('acp', $parent, $module)); + } + + public function test_add() + { + try + { + $this->tool->add('acp', 0, 'ACP_NEW_CAT'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('acp', 0, 'ACP_NEW_CAT')); + + // Should throw an exception when trying to add a module that already exists + try + { + $this->tool->add('acp', 0, 'ACP_NEW_CAT'); + $this->fail('Exception not thrown'); + } + catch (Exception $e) {} + + try + { + $this->tool->add('acp', 'ACP_NEW_CAT', array( + 'module_basename' => 'acp_new_module', + 'module_langname' => 'ACP_NEW_MODULE', + 'module_mode' => 'test', + 'module_auth' => '', + )); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(true, $this->tool->exists('acp', 'ACP_NEW_CAT', 'ACP_NEW_MODULE')); + } + + public function test_remove() + { + try + { + $this->tool->remove('acp', 'ACP_CAT', 'ACP_MODULE'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertEquals(false, $this->tool->exists('acp', 'ACP_CAT', 'ACP_MODULE')); + } + + public function test_reverse() + { + try + { + $this->tool->add('acp', 0, 'ACP_NEW_CAT'); + } + catch (Exception $e) + { + $this->fail($e); + } + + try + { + $this->tool->reverse('add', 'acp', 0, 'ACP_NEW_CAT'); + } + catch (Exception $e) + { + $this->fail($e); + } + $this->assertFalse($this->tool->exists('acp', 0, 'ACP_NEW_CAT')); + } +} |
