[ticket/13733] Remove validate_classes method argument

PHPBB3-13733
This commit is contained in:
Marc Alexander 2016-01-24 22:39:37 +01:00
parent a60935b99d
commit fac4672f3f
2 changed files with 12 additions and 28 deletions

View file

@ -121,11 +121,9 @@ class base implements \phpbb\extension\extension_interface
/** /**
* Get the list of migration files from this extension * Get the list of migration files from this extension
* *
* @var bool $validate_classes Whether or not to check that the migration
* class exists and extends the base migration class.
* @return array * @return array
*/ */
protected function get_migration_file_list($validate_classes = true) protected function get_migration_file_list()
{ {
if ($this->migrations !== false) if ($this->migrations !== false)
{ {
@ -139,24 +137,20 @@ class base implements \phpbb\extension\extension_interface
$migrations = $this->extension_finder->get_classes_from_files($migrations); $migrations = $this->extension_finder->get_classes_from_files($migrations);
if ($validate_classes) // Unset classes that do not exist or do not extend the
// abstract class phpbb\db\migration\migration
foreach ($migrations as $key => $migration)
{ {
// Unset classes that do not exist or do not extend the if (class_exists($migration))
// abstract class phpbb\db\migration\migration
foreach ($migrations as $key => $migration)
{ {
if (class_exists($migration)) $reflector = new \ReflectionClass($migration);
if ($reflector->implementsInterface('\phpbb\db\migration\migration_interface') && $reflector->isInstantiable())
{ {
$reflector = new \ReflectionClass($migration); continue;
if ($reflector->implementsInterface('\phpbb\db\migration\migration_interface') && $reflector->isInstantiable())
{
continue;
}
} }
unset($migrations[$key]);
} }
unset($migrations[$key]);
} }
return $migrations; return $migrations;

View file

@ -64,16 +64,6 @@ class phpbb_extension_extension_base_test extends phpbb_test_case
return array( return array(
array( array(
'vendor2/bar', 'vendor2/bar',
false,
array(
'\vendor2\bar\migrations\bar',
'\vendor2\bar\migrations\foo',
'\vendor2\bar\migrations\migration',
),
),
array(
'vendor2/bar',
true,
array('\vendor2\bar\migrations\migration'), array('\vendor2\bar\migrations\migration'),
), ),
); );
@ -82,10 +72,10 @@ class phpbb_extension_extension_base_test extends phpbb_test_case
/** /**
* @dataProvider data_test_suffix_get_classes * @dataProvider data_test_suffix_get_classes
*/ */
public function test_suffix_get_classes($extension_name, $validate_classes, $expected) public function test_suffix_get_classes($extension_name, $expected)
{ {
$extension = $this->extension_manager->get_extension($extension_name); $extension = $this->extension_manager->get_extension($extension_name);
$migration_classes = self::$reflection_method_get_migration_file_list->invoke($extension, $validate_classes); $migration_classes = self::$reflection_method_get_migration_file_list->invoke($extension);
sort($migration_classes); sort($migration_classes);
$this->assertEquals($expected, $migration_classes); $this->assertEquals($expected, $migration_classes);
} }