Skip to content

Commit

Permalink
add truncate() tests for remaining adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
robmorgan committed Feb 11, 2017
1 parent 2efc990 commit f4a9a0c
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
24 changes: 24 additions & 0 deletions tests/Phinx/Db/Adapter/PostgresAdapterTest.php
Expand Up @@ -913,4 +913,28 @@ public function testInsertData()
$this->assertEquals(1, $rows[0]['column2']);
$this->assertEquals(2, $rows[1]['column2']);
}

public function testTruncateTable()
{
$table = new \Phinx\Db\Table('table1', array(), $this->adapter);
$table->addColumn('column1', 'string')
->addColumn('column2', 'integer')
->insert(array(
array(
'column1' => 'value1',
'column2' => 1,
),
array(
'column1' => 'value2',
'column2' => 2,
)
))
->save();

$rows = $this->adapter->fetchAll('SELECT * FROM table1');
$this->assertEquals(2, count($rows));
$table->truncate();
$rows = $this->adapter->fetchAll('SELECT * FROM table1');
$this->assertEquals(0, count($rows));
}
}
26 changes: 25 additions & 1 deletion tests/Phinx/Db/Adapter/SQLiteAdapterTest.php
Expand Up @@ -668,7 +668,7 @@ public function testInsertData()
$this->assertEquals(null, $rows[3]['column2']);
}

public function testInserDataEnum()
public function testInsertDataEnum()
{
$table = new \Phinx\Db\Table('table1', array(), $this->adapter);
$table->addColumn('column1', 'enum', array('values' => ['a', 'b', 'c']))
Expand Down Expand Up @@ -724,4 +724,28 @@ public function testNullWithoutDefaultValue()
$this->assertEquals(false, $dd->isNull());
$this->assertEquals("some2", $dd->getDefault());
}

public function testTruncateTable()
{
$table = new \Phinx\Db\Table('table1', array(), $this->adapter);
$table->addColumn('column1', 'string')
->addColumn('column2', 'integer')
->insert(array(
array(
'column1' => 'value1',
'column2' => 1,
),
array(
'column1' => 'value2',
'column2' => 2,
)
))
->save();

$rows = $this->adapter->fetchAll('SELECT * FROM table1');
$this->assertEquals(2, count($rows));
$table->truncate();
$rows = $this->adapter->fetchAll('SELECT * FROM table1');
$this->assertEquals(0, count($rows));
}
}
24 changes: 24 additions & 0 deletions tests/Phinx/Db/Adapter/SqlServerAdapterTest.php
Expand Up @@ -698,4 +698,28 @@ public function testInsertData()
$this->assertEquals(2, $rows[1]['column2']);
$this->assertEquals(3, $rows[2]['column2']);
}

public function testTruncateTable()
{
$table = new \Phinx\Db\Table('table1', array(), $this->adapter);
$table->addColumn('column1', 'string')
->addColumn('column2', 'integer')
->insert(array(
array(
'column1' => 'value1',
'column2' => 1,
),
array(
'column1' => 'value2',
'column2' => 2,
)
))
->save();

$rows = $this->adapter->fetchAll('SELECT * FROM table1');
$this->assertEquals(2, count($rows));
$table->truncate();
$rows = $this->adapter->fetchAll('SELECT * FROM table1');
$this->assertEquals(0, count($rows));
}
}

0 comments on commit f4a9a0c

Please sign in to comment.