Skip to content

Commit 10a1bbf

Browse files
committed
Rename methods on Table class.
The word Table is redundant in these methods.
1 parent 0878b17 commit 10a1bbf

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

lib/Cake/Database/Schema/Table.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ public function constraint($name) {
334334
* @return array List of SQL statements to create the table and the
335335
* required indexes.
336336
*/
337-
public function createTableSql(Connection $connection) {
337+
public function createSql(Connection $connection) {
338338
$dialect = $connection->driver()->schemaDialect();
339339
$columns = $constraints = $indexes = [];
340340
foreach (array_keys($this->_columns) as $name) {
@@ -358,8 +358,20 @@ public function createTableSql(Connection $connection) {
358358
* @param Connection $connection The connection to generate SQL for.
359359
* @return string SQL to drop a table.
360360
*/
361-
public function dropTableSql(Connection $connection) {
361+
public function dropSql(Connection $connection) {
362362
$dialect = $connection->driver()->schemaDialect();
363363
return $dialect->dropTableSql($this);
364364
}
365+
366+
/**
367+
* Generate the SQL statements to truncate a table
368+
*
369+
* @param Connection $connection The connection to generate SQL for.
370+
* @return array SQL to drop a table.
371+
*/
372+
public function truncateSql(Connection $connection) {
373+
$dialect = $connection->driver()->schemaDialect();
374+
return $dialect->truncateSql($this);
375+
}
376+
365377
}

lib/Cake/Test/TestCase/Database/Schema/MysqlSchemaTest.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ public function testColumnSqlPrimaryKey() {
523523
*
524524
* @return void
525525
*/
526-
public function testCreateTableSql() {
526+
public function testCreateSql() {
527527
$driver = $this->_getMockedDriver();
528528
$connection = $this->getMock('Cake\Database\Connection', array(), array(), '', false);
529529
$connection->expects($this->any())->method('driver')
@@ -554,27 +554,33 @@ public function testCreateTableSql() {
554554
PRIMARY KEY (`id`)
555555
)
556556
SQL;
557-
$result = $table->createTableSql($connection);
557+
$result = $table->createSql($connection);
558558
$this->assertCount(1, $result);
559559
$this->assertEquals($expected, $result[0]);
560560
}
561561

562562
/**
563-
* test dropTableSql
563+
* test dropSql
564564
*
565565
* @return void
566566
*/
567-
public function testDropTableSql() {
567+
public function testDropSql() {
568568
$driver = $this->_getMockedDriver();
569569
$connection = $this->getMock('Cake\Database\Connection', array(), array(), '', false);
570570
$connection->expects($this->any())->method('driver')
571571
->will($this->returnValue($driver));
572572

573573
$table = new Table('articles');
574-
$result = $table->dropTableSql($connection);
574+
$result = $table->dropSql($connection);
575575
$this->assertEquals('DROP TABLE `articles`', $result);
576576
}
577577

578+
/**
579+
* Test truncateSql()
580+
*/
581+
public function testTruncateSql() {
582+
}
583+
578584
/**
579585
* Get a schema instance with a mocked driver/pdo instances
580586
*

lib/Cake/Test/TestCase/Database/Schema/PostgresSchemaTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ public function testConstraintSql($name, $data, $expected) {
496496
*
497497
* @return void
498498
*/
499-
public function testCreateTableSql() {
499+
public function testCreateSql() {
500500
$driver = $this->_getMockedDriver();
501501
$connection = $this->getMock('Cake\Database\Connection', array(), array(), '', false);
502502
$connection->expects($this->any())->method('driver')
@@ -531,7 +531,7 @@ public function testCreateTableSql() {
531531
PRIMARY KEY ("id")
532532
)
533533
SQL;
534-
$result = $table->createTableSql($connection);
534+
$result = $table->createSql($connection);
535535

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

548548
/**
549-
* test dropTableSql
549+
* test dropSql
550550
*
551551
* @return void
552552
*/
553-
public function testDropTableSql() {
553+
public function testDropSql() {
554554
$driver = $this->_getMockedDriver();
555555
$connection = $this->getMock('Cake\Database\Connection', array(), array(), '', false);
556556
$connection->expects($this->any())->method('driver')
557557
->will($this->returnValue($driver));
558558

559559
$table = new Table('articles');
560-
$result = $table->dropTableSql($connection);
560+
$result = $table->dropSql($connection);
561561
$this->assertEquals('DROP TABLE "articles"', $result);
562562
}
563563

lib/Cake/Test/TestCase/Database/Schema/SqliteSchemaTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ public function testIndexSql($name, $data, $expected) {
479479
*
480480
* @return void
481481
*/
482-
public function testCreateTableSql() {
482+
public function testCreateSql() {
483483
$driver = $this->_getMockedDriver();
484484
$connection = $this->getMock('Cake\Database\Connection', array(), array(), '', false);
485485
$connection->expects($this->any())->method('driver')
@@ -512,7 +512,7 @@ public function testCreateTableSql() {
512512
"created" DATETIME
513513
)
514514
SQL;
515-
$result = $table->createTableSql($connection);
515+
$result = $table->createSql($connection);
516516
$this->assertCount(2, $result);
517517
$this->assertEquals($expected, $result[0]);
518518
$this->assertEquals(
@@ -523,18 +523,18 @@ public function testCreateTableSql() {
523523

524524

525525
/**
526-
* test dropTableSql
526+
* test dropSql
527527
*
528528
* @return void
529529
*/
530-
public function testDropTableSql() {
530+
public function testDropSql() {
531531
$driver = $this->_getMockedDriver();
532532
$connection = $this->getMock('Cake\Database\Connection', array(), array(), '', false);
533533
$connection->expects($this->any())->method('driver')
534534
->will($this->returnValue($driver));
535535

536536
$table = new Table('articles');
537-
$result = $table->dropTableSql($connection);
537+
$result = $table->dropSql($connection);
538538
$this->assertEquals('DROP TABLE "articles"', $result);
539539
}
540540

0 commit comments

Comments
 (0)