Skip to content

Commit 500b9e6

Browse files
committed
add testGetColumns test for sqlite similar to other adapters
Signed-off-by: Matthew Peveler <[email protected]>
1 parent e38444c commit 500b9e6

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

tests/Phinx/Db/Adapter/SQLiteAdapterTest.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,10 +1321,39 @@ public function columnsProvider()
13211321
['column23', 'json', []],
13221322
['decimal_precision_scale', 'decimal', ['precision' => 10, 'scale' => 2]],
13231323
['decimal_precision_zero_scale', 'decimal', ['precision' => 10, 'scale' => 0]],
1324-
['decimal_precision', 'decimal', ['precision' => 10]],
13251324
];
13261325
}
13271326

1327+
/**
1328+
* @dataProvider columnsProvider
1329+
*/
1330+
public function testGetColumns($colName, $type, $options)
1331+
{
1332+
$table = new Table('t', [], $this->adapter);
1333+
$table->addColumn($colName, $type, $options)->save();
1334+
1335+
$columns = $this->adapter->getColumns('t');
1336+
$this->assertCount(2, $columns);
1337+
$this->assertEquals($colName, $columns[1]->getName());
1338+
$this->assertEquals($type, $columns[1]->getType());
1339+
1340+
if (isset($options['limit'])) {
1341+
$this->assertEquals($options['limit'], $columns[1]->getLimit());
1342+
}
1343+
1344+
if (isset($options['precision'])) {
1345+
$this->assertEquals($options['precision'], $columns[1]->getPrecision());
1346+
}
1347+
1348+
if (isset($options['scale'])) {
1349+
$this->assertEquals($options['scale'], $columns[1]->getScale());
1350+
}
1351+
1352+
if (isset($options['comment'])) {
1353+
$this->assertEquals($options['comment'], $columns[1]->getComment());
1354+
}
1355+
}
1356+
13281357
public function testAddIndex()
13291358
{
13301359
$table = new Table('table1', [], $this->adapter);
@@ -3169,7 +3198,7 @@ public function provideColumnNamesToCheck()
31693198
* @covers \Phinx\Db\Adapter\SQLiteAdapter::getTableInfo
31703199
* @covers \Phinx\Db\Adapter\SQLiteAdapter::getColumns
31713200
*/
3172-
public function testGetColumns()
3201+
public function testGetMultipleColumns()
31733202
{
31743203
$conn = $this->adapter->getConnection();
31753204
$conn->exec('create table t(a integer, b text, c char(5), d integer(12,6), e integer not null, f integer null)');

0 commit comments

Comments
 (0)