Skip to content

Commit

Permalink
Add dropTableSql to Sqlite.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed May 25, 2013
1 parent c21a185 commit 0878b17
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/Cake/Database/Schema/SqliteSchema.php
Expand Up @@ -270,4 +270,15 @@ public function createTableSql($table, $columns, $constraints, $indexes) {
}
return $out;
}

/**
* Generate the SQL to drop a table.
*
* @param Cake\Database\Schema\Table $table Table instance
* @return string DROP TABLE sql
*/
public function dropTableSql(Table $table) {
return sprintf('DROP TABLE "%s"', $table->name());
}

}
17 changes: 17 additions & 0 deletions lib/Cake/Test/TestCase/Database/Schema/SqliteSchemaTest.php
Expand Up @@ -521,6 +521,23 @@ public function testCreateTableSql() {
);
}


/**
* test dropTableSql
*
* @return void
*/
public function testDropTableSql() {
$driver = $this->_getMockedDriver();
$connection = $this->getMock('Cake\Database\Connection', array(), array(), '', false);
$connection->expects($this->any())->method('driver')
->will($this->returnValue($driver));

$table = new Table('articles');
$result = $table->dropTableSql($connection);
$this->assertEquals('DROP TABLE "articles"', $result);
}

/**
* Get a schema instance with a mocked driver/pdo instances
*
Expand Down

0 comments on commit 0878b17

Please sign in to comment.