diff options
author | Marc Alexander <admin@m-a-styles.de> | 2014-09-17 00:37:07 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2014-09-17 00:37:07 +0200 |
commit | 5fa2d197566c0f443bbdd71101b6c7876158dea6 (patch) | |
tree | b1284f0f3257d24a155efc974ab4b1482191b7e8 /tests | |
parent | b82a39fea9c48cb36677ed0aaf2dcb5531848d31 (diff) | |
parent | 4a06511d853024193435fd9b2e347ff292589420 (diff) | |
download | forums-5fa2d197566c0f443bbdd71101b6c7876158dea6.tar forums-5fa2d197566c0f443bbdd71101b6c7876158dea6.tar.gz forums-5fa2d197566c0f443bbdd71101b6c7876158dea6.tar.bz2 forums-5fa2d197566c0f443bbdd71101b6c7876158dea6.tar.xz forums-5fa2d197566c0f443bbdd71101b6c7876158dea6.zip |
Merge branch 'develop-ascraeus' into develop
Diffstat (limited to 'tests')
-rw-r--r-- | tests/extension/ext/vendor2/bar/migration/migration.php | 18 | ||||
-rw-r--r-- | tests/extension/ext/vendor2/bar/migrations/migration.php | 18 | ||||
-rw-r--r-- | tests/extension/ext/vendor2/foo/migrations/migration.php | 18 | ||||
-rw-r--r-- | tests/extension/ext/vendor3/bar/migration/migration.php | 18 | ||||
-rw-r--r-- | tests/extension/extension_base_test.php | 85 | ||||
-rw-r--r-- | tests/mock/extension_manager.php | 3 | ||||
-rw-r--r-- | tests/mock/migrator.php | 55 |
7 files changed, 214 insertions, 1 deletions
diff --git a/tests/extension/ext/vendor2/bar/migration/migration.php b/tests/extension/ext/vendor2/bar/migration/migration.php new file mode 100644 index 0000000000..fc27656d10 --- /dev/null +++ b/tests/extension/ext/vendor2/bar/migration/migration.php @@ -0,0 +1,18 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace vendor2\bar\migration; + +class migration extends \phpbb\db\migration\migration +{ +} diff --git a/tests/extension/ext/vendor2/bar/migrations/migration.php b/tests/extension/ext/vendor2/bar/migrations/migration.php new file mode 100644 index 0000000000..71caa34fd9 --- /dev/null +++ b/tests/extension/ext/vendor2/bar/migrations/migration.php @@ -0,0 +1,18 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace vendor2\bar\migrations; + +class migration extends \phpbb\db\migration\migration +{ +} diff --git a/tests/extension/ext/vendor2/foo/migrations/migration.php b/tests/extension/ext/vendor2/foo/migrations/migration.php new file mode 100644 index 0000000000..63085497e3 --- /dev/null +++ b/tests/extension/ext/vendor2/foo/migrations/migration.php @@ -0,0 +1,18 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace vendor2\foo\migrations; + +class migration extends \phpbb\db\migration\migration +{ +} diff --git a/tests/extension/ext/vendor3/bar/migration/migration.php b/tests/extension/ext/vendor3/bar/migration/migration.php new file mode 100644 index 0000000000..e7280a7d5e --- /dev/null +++ b/tests/extension/ext/vendor3/bar/migration/migration.php @@ -0,0 +1,18 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +namespace vendor3\bar\migration; + +class migration extends \phpbb\db\migration\migration +{ +} diff --git a/tests/extension/extension_base_test.php b/tests/extension/extension_base_test.php new file mode 100644 index 0000000000..5535c91fc5 --- /dev/null +++ b/tests/extension/extension_base_test.php @@ -0,0 +1,85 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_extension_extension_base_test extends phpbb_test_case +{ + protected static $reflection_method_get_migration_file_list; + + public static function setUpBeforeClass() + { + parent::setUpBeforeClass(); + + $reflection_class = new ReflectionClass('\phpbb\extension\base'); + self::$reflection_method_get_migration_file_list = $reflection_class->getMethod('get_migration_file_list'); + self::$reflection_method_get_migration_file_list->setAccessible(true); + } + + public function setUp() + { + $container = new phpbb_mock_container_builder(); + $migrator = new phpbb_mock_migrator(); + $container->set('migrator', $migrator); + + $this->extension_manager = new phpbb_mock_extension_manager( + dirname(__FILE__) . '/', + array( + 'vendor2/foo' => array( + 'ext_name' => 'vendor2/foo', + 'ext_active' => '1', + 'ext_path' => 'ext/vendor2/foo/', + ), + 'vendor3/bar' => array( + 'ext_name' => 'vendor3/bar', + 'ext_active' => '1', + 'ext_path' => 'ext/vendor3/bar/', + ), + 'vendor2/bar' => array( + 'ext_name' => 'vendor2/bar', + 'ext_active' => '1', + 'ext_path' => 'ext/vendor2/bar/', + ), + ), + $container); + } + + public function data_test_suffix_get_classes() + { + return array( + array( + 'vendor3/bar', + array('\vendor3\bar\migration\migration'), + ), + array( + 'vendor2/foo', + array('\vendor2\foo\migrations\migration'), + ), + array( + 'vendor2/bar', + array( + '\vendor2\bar\migration\migration', + '\vendor2\bar\migrations\migration', + ), + ), + ); + } + + /** + * @dataProvider data_test_suffix_get_classes + */ + public function test_suffix_get_classes($extension_name, $expected) + { + $extension = $this->extension_manager->get_extension($extension_name); + $this->assertEquals($expected, self::$reflection_method_get_migration_file_list->invoke($extension)); + } +} diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php index 1a475f62e0..3b759fbbc2 100644 --- a/tests/mock/extension_manager.php +++ b/tests/mock/extension_manager.php @@ -13,11 +13,12 @@ class phpbb_mock_extension_manager extends \phpbb\extension\manager { - public function __construct($phpbb_root_path, $extensions = array()) + public function __construct($phpbb_root_path, $extensions = array(), $container = null) { $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = 'php'; $this->extensions = $extensions; $this->filesystem = new \phpbb\filesystem(); + $this->container = $container; } } diff --git a/tests/mock/migrator.php b/tests/mock/migrator.php new file mode 100644 index 0000000000..293f115335 --- /dev/null +++ b/tests/mock/migrator.php @@ -0,0 +1,55 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +class phpbb_mock_migrator extends \phpbb\db\migrator +{ + public function __construct() + { + } + + public function load_migration_state() + { + } + + public function set_migrations($class_names) + { + } + + public function update() + { + } + + public function revert($migration) + { + } + + public function unfulfillable($name) + { + } + + public function finished() + { + } + + public function migration_state($migration) + { + } + + public function populate_migrations($migrations) + { + } + + public function create_migrations_table() + { + } +} |