Skip to content
Permalink
Browse files

The create() and drop() methods should be no-op

Since the user is using an existing table, we should not make any asumption and consider that the table should not be created nor dropped by the TestSuite
  • Loading branch information...
HavokInspiration committed Feb 3, 2016
1 parent b81f889 commit f40dd42de1c0314540230fa255fcf84c5f2b816e
Showing with 20 additions and 4 deletions.
  1. +10 −1 src/TestSuite/Fixture/TestFixture.php
  2. +10 −3 tests/TestCase/TestSuite/TestFixtureTest.php
@@ -244,7 +244,7 @@ protected function _schemaFromReflection()
);
}
$this->_schema = $schema = $db->schemaCollection()->describe($this->table);
$this->_schema = $schemaCollection->describe($this->table);
}
/**
@@ -271,6 +271,10 @@ public function create(ConnectionInterface $db)
return false;
}
if (empty($this->import) && empty($this->fields)) {
return true;
}
try {
$queries = $this->_schema->createSql($db);
foreach ($queries as $query) {
@@ -299,6 +303,11 @@ public function drop(ConnectionInterface $db)
if (empty($this->_schema)) {
return false;
}
if (empty($this->import) && empty($this->fields)) {
return true;
}
try {
$sql = $this->_schema->dropSql($db);
foreach ($sql as $stmt) {
@@ -275,7 +275,7 @@ public function testInitNoImportNoFieldsException()
/**
* test schema reflection without $import or $fields will reflect the schema
*.
*
* @return void
*/
public function testInitNoImportNoFields()
@@ -285,7 +285,7 @@ public function testInitNoImportNoFields()
if (!in_array('letters', $collection->listTables())) {
$table = new Table('letters', [
'id' => ['type' => 'integer'],
'letters' => ['type' => 'integer', 'null' => true]
'letter' => ['type' => 'string', 'length' => 1]
]);
$table->addConstraint('primary', ['type' => 'primary', 'columns' => ['id']]);
$sql = $table->createSql($db);
@@ -297,8 +297,15 @@ public function testInitNoImportNoFields()
$fixture = new LettersFixture();
$fixture->init();
$this->assertEquals(['id', 'letter'], $fixture->schema()->columns());
$this->assertEquals(['id', 'letters'], $fixture->schema()->columns());
$db = $this->getMock('Cake\Database\Connection', ['prepare', 'execute'], [], '', false);
$db->expects($this->never())
->method('prepare');
$db->expects($this->never())
->method('execute');
$this->assertTrue($fixture->create($db));
$this->assertTrue($fixture->drop($db));
}
/**

0 comments on commit f40dd42

Please sign in to comment.
You can’t perform that action at this time.