|
|
@@ -927,6 +927,52 @@ class MysqlTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Test that the primary flag is handled correctly.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testCreateSchemaAutoPrimaryKey() {
|
|
|
+ $schema = new CakeSchema();
|
|
|
+ $schema->tables = array(
|
|
|
+ 'no_indexes' => array(
|
|
|
+ 'id' => array('type' => 'integer', 'null' => false, 'key' => 'primary'),
|
|
|
+ 'data' => array('type' => 'integer', 'null' => false),
|
|
|
+ 'indexes' => array(),
|
|
|
+ )
|
|
|
+ );
|
|
|
+ $result = $this->Dbo->createSchema($schema, 'no_indexes');
|
|
|
+ $this->assertContains('PRIMARY KEY (`id`)', $result);
|
|
|
+ $this->assertNotContains('UNIQUE KEY', $result);
|
|
|
+
|
|
|
+ $schema->tables = array(
|
|
|
+ 'primary_index' => array(
|
|
|
+ 'id' => array('type' => 'integer', 'null' => false),
|
|
|
+ 'data' => array('type' => 'integer', 'null' => false),
|
|
|
+ 'indexes' => array(
|
|
|
+ 'PRIMARY' => array('column' => 'id', 'unique' => 1),
|
|
|
+ 'some_index' => array('column' => 'data', 'unique' => 1)
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ );
|
|
|
+ $result = $this->Dbo->createSchema($schema, 'primary_index');
|
|
|
+ $this->assertContains('PRIMARY KEY (`id`)', $result);
|
|
|
+ $this->assertContains('UNIQUE KEY `some_index` (`data`)', $result);
|
|
|
+
|
|
|
+ $schema->tables = array(
|
|
|
+ 'primary_flag_has_index' => array(
|
|
|
+ 'id' => array('type' => 'integer', 'null' => false, 'key' => 'primary'),
|
|
|
+ 'data' => array('type' => 'integer', 'null' => false),
|
|
|
+ 'indexes' => array (
|
|
|
+ 'some_index' => array('column' => 'data', 'unique' => 1)
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ );
|
|
|
+ $result = $this->Dbo->createSchema($schema, 'primary_flag_has_index');
|
|
|
+ $this->assertContains('PRIMARY KEY (`id`)', $result);
|
|
|
+ $this->assertContains('UNIQUE KEY `some_index` (`data`)', $result);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* Tests that listSources method sends the correct query and parses the result accordingly
|
|
|
* @return void
|
|
|
*/
|