mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Merge branch 'develop-ascraeus' into develop
This commit is contained in:
commit
5fa2d19756
10 changed files with 251 additions and 8 deletions
|
@ -177,11 +177,21 @@ $migrator = $phpbb_container->get('migrator');
|
||||||
$migrator->create_migrations_table();
|
$migrator->create_migrations_table();
|
||||||
|
|
||||||
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
|
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
|
||||||
$finder = $phpbb_extension_manager->get_finder();
|
|
||||||
|
|
||||||
$migrations = $finder
|
$migrations = $phpbb_extension_manager
|
||||||
|
->get_finder()
|
||||||
->core_path('phpbb/db/migration/data/')
|
->core_path('phpbb/db/migration/data/')
|
||||||
|
->extension_directory('/migration')
|
||||||
->get_classes();
|
->get_classes();
|
||||||
|
|
||||||
|
// @deprecated 3.1.0-RC4 (To be removed: 3.2.0)
|
||||||
|
$migrations_deprecated = $phpbb_extension_manager
|
||||||
|
->get_finder()
|
||||||
|
->extension_directory('/migrations')
|
||||||
|
->get_classes();
|
||||||
|
|
||||||
|
$migrations = array_merge($migrations, $migrations_deprecated);
|
||||||
|
|
||||||
$migrator->set_migrations($migrations);
|
$migrator->set_migrations($migrations);
|
||||||
|
|
||||||
// What is a safe limit of execution time? Half the max execution time should be safe.
|
// What is a safe limit of execution time? Half the max execution time should be safe.
|
||||||
|
|
|
@ -117,8 +117,17 @@ class migrate extends \phpbb\console\command\command
|
||||||
$migrations = $this->extension_manager
|
$migrations = $this->extension_manager
|
||||||
->get_finder()
|
->get_finder()
|
||||||
->core_path('phpbb/db/migration/data/')
|
->core_path('phpbb/db/migration/data/')
|
||||||
|
->extension_directory('/migration')
|
||||||
|
->get_classes();
|
||||||
|
|
||||||
|
// @deprecated 3.1.0-RC4 (To be removed: 3.2.0)
|
||||||
|
$migrations_deprecated = $this->extension_manager
|
||||||
|
->get_finder()
|
||||||
->extension_directory('/migrations')
|
->extension_directory('/migrations')
|
||||||
->get_classes();
|
->get_classes();
|
||||||
|
|
||||||
|
$migrations = array_merge($migrations, $migrations_deprecated);
|
||||||
|
|
||||||
$this->migrator->set_migrations($migrations);
|
$this->migrator->set_migrations($migrations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,9 @@ class base implements \phpbb\extension\extension_interface
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $extension_path;
|
protected $extension_path;
|
||||||
|
|
||||||
|
/** @var string[] */
|
||||||
|
private $migrations = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@ -122,18 +125,26 @@ class base implements \phpbb\extension\extension_interface
|
||||||
*/
|
*/
|
||||||
protected function get_migration_file_list()
|
protected function get_migration_file_list()
|
||||||
{
|
{
|
||||||
static $migrations = false;
|
if ($this->migrations !== false)
|
||||||
|
|
||||||
if ($migrations !== false)
|
|
||||||
{
|
{
|
||||||
return $migrations;
|
return $this->migrations;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only have the finder search in this extension path directory
|
// Only have the finder search in this extension path directory
|
||||||
$migrations = $this->extension_finder
|
$migrations = $this->extension_finder
|
||||||
|
->extension_directory('/migration')
|
||||||
|
->find_from_extension($this->extension_name, $this->extension_path);
|
||||||
|
|
||||||
|
$migrations = $this->extension_finder->get_classes_from_files($migrations);
|
||||||
|
|
||||||
|
// @deprecated 3.1.0-RC4 (To be removed: 3.2.0)
|
||||||
|
$migrations_deprecated = $this->extension_finder
|
||||||
->extension_directory('/migrations')
|
->extension_directory('/migrations')
|
||||||
->find_from_extension($this->extension_name, $this->extension_path);
|
->find_from_extension($this->extension_name, $this->extension_path);
|
||||||
$migrations = $this->extension_finder->get_classes_from_files($migrations);
|
|
||||||
|
$migrations_deprecated = $this->extension_finder->get_classes_from_files($migrations_deprecated);
|
||||||
|
|
||||||
|
$migrations = array_merge($migrations, $migrations_deprecated);
|
||||||
|
|
||||||
return $migrations;
|
return $migrations;
|
||||||
}
|
}
|
||||||
|
|
18
tests/extension/ext/vendor2/bar/migration/migration.php
Normal file
18
tests/extension/ext/vendor2/bar/migration/migration.php
Normal file
|
@ -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
|
||||||
|
{
|
||||||
|
}
|
18
tests/extension/ext/vendor2/bar/migrations/migration.php
Normal file
18
tests/extension/ext/vendor2/bar/migrations/migration.php
Normal file
|
@ -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
|
||||||
|
{
|
||||||
|
}
|
18
tests/extension/ext/vendor2/foo/migrations/migration.php
Normal file
18
tests/extension/ext/vendor2/foo/migrations/migration.php
Normal file
|
@ -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
|
||||||
|
{
|
||||||
|
}
|
18
tests/extension/ext/vendor3/bar/migration/migration.php
Normal file
18
tests/extension/ext/vendor3/bar/migration/migration.php
Normal file
|
@ -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
|
||||||
|
{
|
||||||
|
}
|
85
tests/extension/extension_base_test.php
Normal file
85
tests/extension/extension_base_test.php
Normal file
|
@ -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));
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,11 +13,12 @@
|
||||||
|
|
||||||
class phpbb_mock_extension_manager extends \phpbb\extension\manager
|
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->phpbb_root_path = $phpbb_root_path;
|
||||||
$this->php_ext = 'php';
|
$this->php_ext = 'php';
|
||||||
$this->extensions = $extensions;
|
$this->extensions = $extensions;
|
||||||
$this->filesystem = new \phpbb\filesystem();
|
$this->filesystem = new \phpbb\filesystem();
|
||||||
|
$this->container = $container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
55
tests/mock/migrator.php
Normal file
55
tests/mock/migrator.php
Normal file
|
@ -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()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue