Skip to content

Commit

Permalink
Rename methods on Table class.
Browse files Browse the repository at this point in the history
The word Table is redundant in these methods.
  • Loading branch information
markstory committed May 25, 2013
1 parent 0878b17 commit 10a1bbf
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
16 changes: 14 additions & 2 deletions lib/Cake/Database/Schema/Table.php
Expand Up @@ -334,7 +334,7 @@ public function constraint($name) {
* @return array List of SQL statements to create the table and the
* required indexes.
*/
public function createTableSql(Connection $connection) {
public function createSql(Connection $connection) {
$dialect = $connection->driver()->schemaDialect();
$columns = $constraints = $indexes = [];
foreach (array_keys($this->_columns) as $name) {
Expand All @@ -358,8 +358,20 @@ public function createTableSql(Connection $connection) {
* @param Connection $connection The connection to generate SQL for.
* @return string SQL to drop a table.
*/
public function dropTableSql(Connection $connection) {
public function dropSql(Connection $connection) {
$dialect = $connection->driver()->schemaDialect();
return $dialect->dropTableSql($this);
}

/**
* Generate the SQL statements to truncate a table
*
* @param Connection $connection The connection to generate SQL for.
* @return array SQL to drop a table.
*/
public function truncateSql(Connection $connection) {
$dialect = $connection->driver()->schemaDialect();
return $dialect->truncateSql($this);
}

}
16 changes: 11 additions & 5 deletions lib/Cake/Test/TestCase/Database/Schema/MysqlSchemaTest.php
Expand Up @@ -523,7 +523,7 @@ public function testColumnSqlPrimaryKey() {
*
* @return void
*/
public function testCreateTableSql() {
public function testCreateSql() {
$driver = $this->_getMockedDriver();
$connection = $this->getMock('Cake\Database\Connection', array(), array(), '', false);
$connection->expects($this->any())->method('driver')
Expand Down Expand Up @@ -554,27 +554,33 @@ public function testCreateTableSql() {
PRIMARY KEY (`id`)
)
SQL;
$result = $table->createTableSql($connection);
$result = $table->createSql($connection);
$this->assertCount(1, $result);
$this->assertEquals($expected, $result[0]);
}

/**
* test dropTableSql
* test dropSql
*
* @return void
*/
public function testDropTableSql() {
public function testDropSql() {
$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);
$result = $table->dropSql($connection);
$this->assertEquals('DROP TABLE `articles`', $result);
}

/**
* Test truncateSql()
*/
public function testTruncateSql() {
}

/**
* Get a schema instance with a mocked driver/pdo instances
*
Expand Down
10 changes: 5 additions & 5 deletions lib/Cake/Test/TestCase/Database/Schema/PostgresSchemaTest.php
Expand Up @@ -496,7 +496,7 @@ public function testConstraintSql($name, $data, $expected) {
*
* @return void
*/
public function testCreateTableSql() {
public function testCreateSql() {
$driver = $this->_getMockedDriver();
$connection = $this->getMock('Cake\Database\Connection', array(), array(), '', false);
$connection->expects($this->any())->method('driver')
Expand Down Expand Up @@ -531,7 +531,7 @@ public function testCreateTableSql() {
PRIMARY KEY ("id")
)
SQL;
$result = $table->createTableSql($connection);
$result = $table->createSql($connection);

$this->assertCount(3, $result);
$this->assertEquals($expected, $result[0]);
Expand All @@ -546,18 +546,18 @@ public function testCreateTableSql() {
}

/**
* test dropTableSql
* test dropSql
*
* @return void
*/
public function testDropTableSql() {
public function testDropSql() {
$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);
$result = $table->dropSql($connection);
$this->assertEquals('DROP TABLE "articles"', $result);
}

Expand Down
10 changes: 5 additions & 5 deletions lib/Cake/Test/TestCase/Database/Schema/SqliteSchemaTest.php
Expand Up @@ -479,7 +479,7 @@ public function testIndexSql($name, $data, $expected) {
*
* @return void
*/
public function testCreateTableSql() {
public function testCreateSql() {
$driver = $this->_getMockedDriver();
$connection = $this->getMock('Cake\Database\Connection', array(), array(), '', false);
$connection->expects($this->any())->method('driver')
Expand Down Expand Up @@ -512,7 +512,7 @@ public function testCreateTableSql() {
"created" DATETIME
)
SQL;
$result = $table->createTableSql($connection);
$result = $table->createSql($connection);
$this->assertCount(2, $result);
$this->assertEquals($expected, $result[0]);
$this->assertEquals(
Expand All @@ -523,18 +523,18 @@ public function testCreateTableSql() {


/**
* test dropTableSql
* test dropSql
*
* @return void
*/
public function testDropTableSql() {
public function testDropSql() {
$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);
$result = $table->dropSql($connection);
$this->assertEquals('DROP TABLE "articles"', $result);
}

Expand Down

0 comments on commit 10a1bbf

Please sign in to comment.