mirror of
https://github.com/Oreolek/kohana-migrations.git
synced 2024-05-05 02:28:16 +03:00
adjusting the old util classes to run in the model tests (refs #11)
This commit is contained in:
parent
307181ccc4
commit
0c65956d6b
|
@ -44,7 +44,7 @@ class Minion_Migration_ModelTest extends Kohana_Unittest_Database_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* Get an instance of the migration model, pre-loaded with a connection to
|
||||
* Get an instance of the migration model, pre-loaded with a connection to
|
||||
* the test database
|
||||
*
|
||||
* @return Model_Minion_Migration
|
||||
|
@ -331,7 +331,7 @@ class Minion_Migration_ModelTest extends Kohana_Unittest_Database_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that Model_Minion_Migration::get_migration can get a migration from
|
||||
* Tests that Model_Minion_Migration::get_migration can get a migration from
|
||||
* the database
|
||||
*
|
||||
* @test
|
||||
|
@ -363,7 +363,7 @@ class Minion_Migration_ModelTest extends Kohana_Unittest_Database_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* If invalid input is passed to get_migration then it should throw an
|
||||
* If invalid input is passed to get_migration then it should throw an
|
||||
* exception
|
||||
*
|
||||
* @test
|
||||
|
@ -418,7 +418,7 @@ class Minion_Migration_ModelTest extends Kohana_Unittest_Database_TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that Model_Minion_Migration::mark_migration() changes the applied
|
||||
* Tests that Model_Minion_Migration::mark_migration() changes the applied
|
||||
* status of a migration
|
||||
*
|
||||
* @test
|
||||
|
@ -495,4 +495,162 @@ class Minion_Migration_ModelTest extends Kohana_Unittest_Database_TestCase
|
|||
$this->getModel()->resolve_target( (array) $group, $target)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides test data for test_compile_migrations_from_files()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provider_compile_migrations_from_files()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'myapp:015151051' => array('group' => 'myapp', 'description' => 'setup', 'timestamp' => '015151051', 'id' => 'myapp:015151051'),
|
||||
'myapp:015161051' => array('group' => 'myapp', 'description' => 'add-comments', 'timestamp' => '015161051', 'id' => 'myapp:015161051'),
|
||||
),
|
||||
array(
|
||||
'migrations/myapp' => array(
|
||||
'migrations/myapp/015151051_setup.php'
|
||||
=> '/var/www/app/groups/myapp/migrations/myapp/015151051_setup.php',
|
||||
'migrations/myapp/015161051_add-comments.php'
|
||||
=> '/var/www/app/groups/myapp/migrations/myapp/015161051_add-comments.php',
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that Minion_Migration_Util::compile_migrations_from_files accurately
|
||||
* compiles a set of files down into a set of migration files
|
||||
*
|
||||
* @test
|
||||
* @covers Minion_Migration_Util::compile_migrations_from_files
|
||||
* @dataProvider provider_compile_migrations_from_files
|
||||
* @param array Expected output
|
||||
* @param array Input Files
|
||||
*/
|
||||
public function test_compile_migrations_from_files($expected, array $files)
|
||||
{
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->getModel()->compile_migrations_from_files($files)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides test data for test_extract_migration_info_from_filename
|
||||
*
|
||||
* @return array Test Data
|
||||
*/
|
||||
public function provider_get_migration_from_filename()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'group' => 'myapp',
|
||||
'description' => 'initial-setup',
|
||||
'timestamp' => '1293214439',
|
||||
'id' => 'myapp:1293214439',
|
||||
),
|
||||
'migrations/myapp/1293214439_initial-setup.php',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Minion_Migration_Util::get_migration_info_from_filename()
|
||||
* correctly extracts information about the migration from its filename
|
||||
*
|
||||
* @test
|
||||
* @covers Minion_Migration_Util::get_migration_from_filename
|
||||
* @dataProvider provider_get_migration_from_filename
|
||||
* @param array Expected output
|
||||
* @param string Input filename
|
||||
*/
|
||||
public function test_get_migration_from_filename($expected, $file)
|
||||
{
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->getModel()->get_migration_from_filename($file)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides test data for test_convert_migration_to_filename
|
||||
*
|
||||
* @return array Test Data
|
||||
*/
|
||||
public function provider_get_filename_from_migration()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'myapp/1293214439_initial-setup.php',
|
||||
array(
|
||||
'group' => 'myapp',
|
||||
'timestamp' => '1293214439',
|
||||
'description' => 'initial-setup',
|
||||
'id' => 'myapp:1293214439'
|
||||
),
|
||||
'myapp',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Minion_Migration_Util::get_filename_from_migration generates
|
||||
* accurate filenames when given a variety of migration information
|
||||
*
|
||||
* @test
|
||||
* @covers Minion_Migration_Util::get_filename_from_migration
|
||||
* @dataProvider provider_get_filename_from_migration
|
||||
* @param string Expected output
|
||||
* @param mixed Migration id
|
||||
* @param mixed group
|
||||
*/
|
||||
public function test_get_filename_from_migration($expected, $migration, $group)
|
||||
{
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->getModel()->get_filename_from_migration($migration, $group)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides test data for test_get_class_from_migration
|
||||
*
|
||||
* @return array Test Data
|
||||
*/
|
||||
public function provider_get_class_from_migration()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'Migration_Kohana_201012290258',
|
||||
'kohana:201012290258',
|
||||
),
|
||||
array(
|
||||
'Migration_Kohana_201012290258',
|
||||
array('group' => 'kohana', 'timestamp' => '201012290258'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Minion_Migration_Util::get_class_from_migration can generate
|
||||
* a class name from information about a migration
|
||||
*
|
||||
* @test
|
||||
* @covers Minion_Migration_Util::get_class_from_migration
|
||||
* @dataProvider provider_get_class_from_migration
|
||||
* @param string Expected output
|
||||
* @param string|array Migration info
|
||||
*/
|
||||
public function test_get_class_from_migration($expected, $migration)
|
||||
{
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->getModel()->get_class_from_migration($migration)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,169 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Testcase for Minion_Migration_Util
|
||||
*
|
||||
* @group minion
|
||||
* @group minion.tasks
|
||||
* @group minion.tasks.migrations
|
||||
*/
|
||||
class Minion_Migration_UtilTest extends Kohana_Unittest_TestCase {
|
||||
|
||||
/**
|
||||
* Provides test data for test_compile_migrations_from_files()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provider_compile_migrations_from_files()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'myapp:015151051' => array('group' => 'myapp', 'description' => 'setup', 'timestamp' => '015151051', 'id' => 'myapp:015151051'),
|
||||
'myapp:015161051' => array('group' => 'myapp', 'description' => 'add-comments', 'timestamp' => '015161051', 'id' => 'myapp:015161051'),
|
||||
),
|
||||
array(
|
||||
'migrations/myapp' => array(
|
||||
'migrations/myapp/015151051_setup.php'
|
||||
=> '/var/www/app/groups/myapp/migrations/myapp/015151051_setup.php',
|
||||
'migrations/myapp/015161051_add-comments.php'
|
||||
=> '/var/www/app/groups/myapp/migrations/myapp/015161051_add-comments.php',
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that Minion_Migration_Util::compile_migrations_from_files accurately
|
||||
* compiles a set of files down into a set of migration files
|
||||
*
|
||||
* @test
|
||||
* @covers Minion_Migration_Util::compile_migrations_from_files
|
||||
* @dataProvider provider_compile_migrations_from_files
|
||||
* @param array Expected output
|
||||
* @param array Input Files
|
||||
*/
|
||||
public function test_compile_migrations_from_files($expected, array $files)
|
||||
{
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
Minion_Migration_Util::compile_migrations_from_files($files)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides test data for test_extract_migration_info_from_filename
|
||||
*
|
||||
* @return array Test Data
|
||||
*/
|
||||
public function provider_get_migration_from_filename()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'group' => 'myapp',
|
||||
'description' => 'initial-setup',
|
||||
'timestamp' => '1293214439',
|
||||
'id' => 'myapp:1293214439',
|
||||
),
|
||||
'migrations/myapp/1293214439_initial-setup.php',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Minion_Migration_Util::get_migration_info_from_filename()
|
||||
* correctly extracts information about the migration from its filename
|
||||
*
|
||||
* @test
|
||||
* @covers Minion_Migration_Util::get_migration_from_filename
|
||||
* @dataProvider provider_get_migration_from_filename
|
||||
* @param array Expected output
|
||||
* @param string Input filename
|
||||
*/
|
||||
public function test_get_migration_from_filename($expected, $file)
|
||||
{
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
Minion_Migration_Util::get_migration_from_filename($file)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides test data for test_convert_migration_to_filename
|
||||
*
|
||||
* @return array Test Data
|
||||
*/
|
||||
public function provider_get_filename_from_migration()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'myapp/1293214439_initial-setup.php',
|
||||
array(
|
||||
'group' => 'myapp',
|
||||
'timestamp' => '1293214439',
|
||||
'description' => 'initial-setup',
|
||||
'id' => 'myapp:1293214439'
|
||||
),
|
||||
'myapp',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Minion_Migration_Util::get_filename_from_migration generates
|
||||
* accurate filenames when given a variety of migration information
|
||||
*
|
||||
* @test
|
||||
* @covers Minion_Migration_Util::get_filename_from_migration
|
||||
* @dataProvider provider_get_filename_from_migration
|
||||
* @param string Expected output
|
||||
* @param mixed Migration id
|
||||
* @param mixed group
|
||||
*/
|
||||
public function test_get_filename_from_migration($expected, $migration, $group)
|
||||
{
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
Minion_Migration_Util::get_filename_from_migration($migration, $group)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides test data for test_get_class_from_migration
|
||||
*
|
||||
* @return array Test Data
|
||||
*/
|
||||
public function provider_get_class_from_migration()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'Migration_Kohana_201012290258',
|
||||
'kohana:201012290258',
|
||||
),
|
||||
array(
|
||||
'Migration_Kohana_201012290258',
|
||||
array('group' => 'kohana', 'timestamp' => '201012290258'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Minion_Migration_Util::get_class_from_migration can generate
|
||||
* a class name from information about a migration
|
||||
*
|
||||
* @test
|
||||
* @covers Minion_Migration_Util::get_class_from_migration
|
||||
* @dataProvider provider_get_class_from_migration
|
||||
* @param string Expected output
|
||||
* @param string|array Migration info
|
||||
*/
|
||||
public function test_get_class_from_migration($expected, $migration)
|
||||
{
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
Minion_Migration_Util::get_class_from_migration($migration)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue