Permalink
Browse files

Fixing broken tests and features

  • Loading branch information...
1 parent f648a1f commit 915eb10fecd1ef0ad4595747166fee18d37eeed4 @lorenzo lorenzo committed Apr 14, 2012
View
@@ -96,7 +96,11 @@ public function getVersion($type) {
* @return boolean
*/
public function setVersion($version, $type, $migrated = true) {
+ if ($type !== 'app') {
+ $type = Inflector::camelize($type);
+ }
$mapping = $this->getMapping($type);
+
// For BC, 002 was not applied yet.
$bc = ($this->Version->schema('class') === null);
$field = $bc ? 'version' : 'class';
@@ -182,7 +186,7 @@ public function getMapping($type, $cache = true) {
} else {
if (isset($migrated[$class])) {
$mapping[$version]['migrated'] = $migrated[$class];
- } elseif (isset($bcMapping[$class])) {
+ } elseif (isset($bcMapping[$class]) && !empty($migrated[$bcMapping[$class]])) {
$mapping[$version]['migrated'] = $migrated[$bcMapping[$class]];
}
}
@@ -723,10 +723,7 @@ public function testGenerateComparison() {
$this->Shell->expects($this->at(4))->method('in')->will($this->returnValue('y'));
$this->Shell->expects($this->at(5))->method('dispatchShell')->with('schema generate --connection test --force');
- $mapping = array(
- gmdate('U') => array('class' => 'M4af9d15154844819b7a0007058157726')
- );
- $this->Shell->Version->expects($this->any())->method('getMapping')->will($this->returnValue($mapping));
+ $this->Shell->Version->expects($this->any())->method('getMapping')->will($this->returnCallback(array($this, 'returnMapping')));
$this->assertEmpty(glob(TMP . 'tests' . DS . '*drop_slug_field.php'));
$this->Shell->params['force'] = true;
@@ -757,6 +754,12 @@ public function testGenerateComparison() {
$this->assertPattern(str_replace("\r\n", "\n", $pattern), $result);
}
+ public function returnMapping() {
+ return array(
+ gmdate('U') => array('class' => 'M4af9d15154844819b7a0007058157726')
+ );
+ }
+
/**
* testGenerateDump method
*
@@ -770,7 +773,7 @@ public function testGenerateDump() {
$mapping = array(
gmdate('U') => array('class' => 'M4af9d15154844819b7a0007058157726')
);
- $this->Shell->Version->expects($this->any())->method('getMapping')->will($this->returnValue($mapping));
+ $this->Shell->Version->expects($this->any())->method('getMapping')->will($this->returnCallback(array($this, 'returnMapping')));
$this->assertEmpty(glob(TMP . 'tests' . DS . '*schema_dump.php'));
$this->Shell->type = 'TestMigrationPlugin2';
@@ -783,6 +786,7 @@ public function testGenerateDump() {
foreach ($files as $f) {
unlink($f);
}
+
$expected = file_get_contents(CakePlugin::path('Migrations') . '/Test/Fixture/test_migration.txt');
$this->assertEquals($expected, $result);
}
@@ -72,8 +72,8 @@ public function testGetMapping() {
1 => array(
'version' => 1,
'name' => '001_schema_dump',
- 'class' => 'SchemaDump',
- 'type' => 'test_migration_plugin',
+ 'class' => 'M4af6d40056b04408808500cb58157726',
+ 'type' => 'TestMigrationPlugin',
'migrated' => null
)
);
@@ -85,14 +85,14 @@ public function testGetMapping() {
'version' => 1,
'name' => '001_init_migrations',
'class' => 'InitMigrations',
- 'type' => 'migrations',
+ 'type' => 'Migrations',
'migrated' => '2009-11-10 00:55:34'
),
2 => array(
'version' => 2,
'name' => '002_convert_version_to_class_names',
'class' => 'ConvertVersionToClassNames',
- 'type' => 'migrations',
+ 'type' => 'Migrations',
'migrated' => '2011-11-18 13:53:32'
)
);
@@ -29,8 +29,8 @@
),
'users' => array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'key' => 'primary'),
- 'user' => array('type' => 'string', 'null' => false, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
- 'password' => array('type' => 'string', 'null' => false, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+ 'user' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+ 'password' => array('type' => 'string', 'null' => true, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'created' => array('type' => 'datetime', 'null' => true, 'default' => NULL),
'updated' => array('type' => 'datetime', 'null' => true, 'default' => NULL),
'indexes' => array(

0 comments on commit 915eb10

Please sign in to comment.