mirror of
https://github.com/Oreolek/kohana-migrations.git
synced 2024-06-26 03:40:54 +03:00
Renaming some methods and changing get_filename_from_migration() so it doesn't prepend migrations/
This commit is contained in:
parent
76f50ab4b9
commit
1d3e2343c9
|
@ -28,9 +28,12 @@ class Minion_Migration_Util {
|
|||
}
|
||||
else
|
||||
{
|
||||
$migration = Minion_Migration_Util::extract_migration_info_from_filename($file);
|
||||
$migration = Minion_Migration_Util::get_migration_from_filename($file);
|
||||
|
||||
$migrations[$migration['id']] = array('file' => $file, 'location' => $migration['location']);
|
||||
$migrations[$migration['id']] = array(
|
||||
'file' => $file,
|
||||
'location' => $migration['location']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +56,7 @@ class Minion_Migration_Util {
|
|||
* @param string The migration's filename
|
||||
* @return array Array of components about the migration
|
||||
*/
|
||||
public static function extract_migration_info_from_filename($file)
|
||||
public static function get_migration_from_filename($file)
|
||||
{
|
||||
$migration = array();
|
||||
|
||||
|
@ -77,15 +80,16 @@ class Minion_Migration_Util {
|
|||
* @param string The migration location
|
||||
* @return string Path to the migration file
|
||||
*/
|
||||
public static function convert_migration_to_filename($migration, $location)
|
||||
public static function get_filename_from_migration($migration, $location)
|
||||
{
|
||||
if(is_array($migration))
|
||||
{
|
||||
$migration = implode('_', $migration);
|
||||
$location = $migration['location'];
|
||||
$migration = $migration['id'];
|
||||
}
|
||||
|
||||
$location = ! empty($location) ? rtrim($location, '/').'/' : '';
|
||||
|
||||
return 'migrations/'.$location.$migration.EXT;
|
||||
return $location.$migration.EXT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ class Minion_Migration_UtilTest extends Kohana_Unittest_TestCase {
|
|||
*
|
||||
* @return array Test Data
|
||||
*/
|
||||
public function provider_extract_migration_info_from_filename()
|
||||
public function provider_get_migration_from_filename()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
|
@ -72,20 +72,20 @@ class Minion_Migration_UtilTest extends Kohana_Unittest_TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that Minion_Migration_Util::extract_migration_info_from_filename()
|
||||
* Tests that Minion_Migration_Util::get_migration_info_from_filename()
|
||||
* correctly extracts information about the migration from its filename
|
||||
*
|
||||
* @test
|
||||
* @covers Minion_Migration_Util::extract_migration_info_from_filename
|
||||
* @dataProvider provider_extract_migration_info_from_filename
|
||||
* @dataProvider provider_convert_file_to_migration_info
|
||||
* @param array Expected output
|
||||
* @param string Input filename
|
||||
*/
|
||||
public function test_extract_migration_info_from_filename($expected, $file)
|
||||
public function test_get_migration_from_filename($expected, $file)
|
||||
{
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
Minion_Migration_Util::extract_migration_info_from_filename($file)
|
||||
Minion_Migration_Util::get_migration_from_filename($file)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -94,11 +94,11 @@ class Minion_Migration_UtilTest extends Kohana_Unittest_TestCase {
|
|||
*
|
||||
* @return array Test Data
|
||||
*/
|
||||
public function provider_convert_migration_to_filename()
|
||||
public function provider_get_filename_from_migration()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'migrations/myapp/1293214439_initial-setup.php',
|
||||
'myapp/1293214439_initial-setup.php',
|
||||
'1293214439_initial-setup',
|
||||
'myapp',
|
||||
),
|
||||
|
@ -106,7 +106,7 @@ class Minion_Migration_UtilTest extends Kohana_Unittest_TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that Minion_Migration_Util::convert_migration_to_filename generates
|
||||
* Tests that Minion_Migration_Util::get_filename_from_migration generates
|
||||
* accurate filenames when given a variety of migration information
|
||||
*
|
||||
* @test
|
||||
|
@ -116,11 +116,11 @@ class Minion_Migration_UtilTest extends Kohana_Unittest_TestCase {
|
|||
* @param mixed Migration id
|
||||
* @param mixed location
|
||||
*/
|
||||
public function test_convert_migration_to_filename($expected, $migration, $location)
|
||||
public function test_get_filename_from_migration($expected, $migration, $location)
|
||||
{
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
Minion_Migration_Util::convert_migration_to_filename($migration, $location)
|
||||
Minion_Migration_Util::get_filename_from_migration($migration, $location)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue