mirror of
https://github.com/Oreolek/kohana-migrations.git
synced 2024-06-26 03:40:54 +03:00
Changing tests to auto-create and auto-teardown the testing table fixes #5
This commit is contained in:
parent
12670e28ef
commit
17b36782e1
|
@ -1,34 +0,0 @@
|
||||||
<?php defined('SYSPATH') or die('No direct script access.');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create test_minion_migrations table
|
|
||||||
*/
|
|
||||||
class Migration_Minion_20110110093709 extends Minion_Migration_Base {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run queries needed to apply this migration
|
|
||||||
*
|
|
||||||
* @param Kohana_Database Database connection
|
|
||||||
*/
|
|
||||||
public function up(Kohana_Database $db)
|
|
||||||
{
|
|
||||||
$db->query(NULL, 'CREATE TABLE `test_minion_migrations` (
|
|
||||||
`timestamp` varchar(14) NOT NULL,
|
|
||||||
`description` varchar(100) NOT NULL,
|
|
||||||
`location` varchar(100) NOT NULL,
|
|
||||||
`applied` tinyint(1) DEFAULT \'0\',
|
|
||||||
PRIMARY KEY (`timestamp`,`location`),
|
|
||||||
UNIQUE KEY `MIGRATION_ID` (`timestamp`,`description`)
|
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run queries needed to remove this migration
|
|
||||||
*
|
|
||||||
* @param Kohana_Database Database connection
|
|
||||||
*/
|
|
||||||
public function down(Kohana_Database $db)
|
|
||||||
{
|
|
||||||
$db->query(NULL, 'DROP TABLE `test_minion_migrations`');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,9 +4,33 @@
|
||||||
* Test for the migration model
|
* Test for the migration model
|
||||||
*
|
*
|
||||||
* @group minion
|
* @group minion
|
||||||
**/
|
* @group minion.tasks
|
||||||
|
* @group minion.tasks.migrations
|
||||||
|
*/
|
||||||
class Minion_Migration_ModelTest extends Kohana_Unittest_Database_TestCase
|
class Minion_Migration_ModelTest extends Kohana_Unittest_Database_TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Runs before the test class as a whole is ran
|
||||||
|
* Creates the test table
|
||||||
|
*/
|
||||||
|
public static function setUpBeforeClass()
|
||||||
|
{
|
||||||
|
$sql = file_get_contents(Kohana::find_file('', 'minion_schema', 'sql'));
|
||||||
|
|
||||||
|
$sql = str_replace('`minion_migrations`', '`test_minion_migrations`', $sql);
|
||||||
|
|
||||||
|
Database::instance()->query(NULL, 'DROP TABLE IF EXISTS `test_minion_migrations`');
|
||||||
|
Database::instance()->query(NULL, $sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the test tables after the tests have finished
|
||||||
|
*/
|
||||||
|
public static function tearDownAfterClass()
|
||||||
|
{
|
||||||
|
Database::instance()->query(NULL, 'DROP TABLE `test_minion_migrations`');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the dataset that should be used to populate db
|
* Gets the dataset that should be used to populate db
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue