Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Apr 11, 2020
1 parent bb3d76f commit 58dca0c
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/Phinx/Db/Adapter/MysqlAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,40 @@ public function testCreateTableWithMultiplePrimaryKeys()
$this->assertFalse($this->adapter->hasIndex('table1', ['tag_id', 'user_email']));
}

/**
* @return void
*/
public function testCreateTableWithPrimaryKeyAsUuid()
{
$options = [
'id' => false,
'primary_key' => 'id',
];
$table = new \Phinx\Db\Table('ztable', $options, $this->adapter);
$table->addColumn('id', 'uuid')->save();
$table->addColumn('user_id', 'integer')->save();
$this->assertTrue($this->adapter->hasColumn('ztable', 'id'));
$this->assertTrue($this->adapter->hasIndex('ztable', 'id'));
$this->assertTrue($this->adapter->hasColumn('ztable', 'user_id'));
}

/**
* @return void
*/
public function testCreateTableWithPrimaryKeyAsBinaryUuid()
{
$options = [
'id' => false,
'primary_key' => 'id',
];
$table = new \Phinx\Db\Table('ztable', $options, $this->adapter);
$table->addColumn('id', 'binaryuuid')->save();
$table->addColumn('user_id', 'integer')->save();
$this->assertTrue($this->adapter->hasColumn('ztable', 'id'));
$this->assertTrue($this->adapter->hasIndex('ztable', 'id'));
$this->assertTrue($this->adapter->hasColumn('ztable', 'user_id'));
}

public function testCreateTableWithMultipleIndexes()
{
$table = new \Phinx\Db\Table('table1', [], $this->adapter);
Expand Down
34 changes: 34 additions & 0 deletions tests/Phinx/Db/Adapter/PostgresAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,40 @@ public function testCreateTableWithMultiplePrimaryKeysWithSchema()
$this->adapter->dropSchema('schema1');
}

/**
* @return void
*/
public function testCreateTableWithPrimaryKeyAsUuid()
{
$options = [
'id' => false,
'primary_key' => 'id',
];
$table = new \Phinx\Db\Table('ztable', $options, $this->adapter);
$table->addColumn('id', 'uuid')->save();
$table->addColumn('user_id', 'integer')->save();
$this->assertTrue($this->adapter->hasColumn('ztable', 'id'));
$this->assertTrue($this->adapter->hasIndex('ztable', 'id'));
$this->assertTrue($this->adapter->hasColumn('ztable', 'user_id'));
}

/**
* @return void
*/
public function testCreateTableWithPrimaryKeyAsBinaryUuid()
{
$options = [
'id' => false,
'primary_key' => 'id',
];
$table = new \Phinx\Db\Table('ztable', $options, $this->adapter);
$table->addColumn('id', 'binaryuuid')->save();
$table->addColumn('user_id', 'integer')->save();
$this->assertTrue($this->adapter->hasColumn('ztable', 'id'));
$this->assertTrue($this->adapter->hasIndex('ztable', 'id'));
$this->assertTrue($this->adapter->hasColumn('ztable', 'user_id'));
}

public function testCreateTableWithMultipleIndexes()
{
$table = new \Phinx\Db\Table('table1', [], $this->adapter);
Expand Down
31 changes: 31 additions & 0 deletions tests/Phinx/Db/Adapter/SQLiteAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,36 @@ public function testCreateTableWithMultiplePrimaryKeys()
$this->assertFalse($this->adapter->hasIndex('table1', ['tag_id', 'user_email']));
}

/**
* @return void
*/
public function testCreateTableWithPrimaryKeyAsUuid()
{
$options = [
'id' => false,
'primary_key' => 'id',
];
$table = new \Phinx\Db\Table('ztable', $options, $this->adapter);
$table->addColumn('id', 'uuid')->save();
$this->assertTrue($this->adapter->hasColumn('ztable', 'id'));
$this->assertTrue($this->adapter->hasIndex('ztable', 'id'));
}

/**
* @return void
*/
public function testCreateTableWithPrimaryKeyAsBinaryUuid()
{
$options = [
'id' => false,
'primary_key' => 'id',
];
$table = new \Phinx\Db\Table('ztable', $options, $this->adapter);
$table->addColumn('id', 'binaryuuid')->save();
$this->assertTrue($this->adapter->hasColumn('ztable', 'id'));
$this->assertTrue($this->adapter->hasIndex('ztable', 'id'));
}

public function testCreateTableWithMultipleIndexes()
{
$table = new \Phinx\Db\Table('table1', [], $this->adapter);
Expand Down Expand Up @@ -1649,6 +1679,7 @@ public function testGetColumnTypes()
SQLiteAdapter::PHINX_TYPE_TEXT,
SQLiteAdapter::PHINX_TYPE_TIME,
SQLiteAdapter::PHINX_TYPE_UUID,
SQLiteAdapter::PHINX_TYPE_BINARYUUID,
SQLiteAdapter::PHINX_TYPE_TIMESTAMP,
SQLiteAdapter::PHINX_TYPE_VARBINARY,
];
Expand Down

0 comments on commit 58dca0c

Please sign in to comment.