Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOdin committed Nov 3, 2023
1 parent 0f029e8 commit 3358d0c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/Phinx/Db/Adapter/MysqlAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,19 @@ public function testDropPrimaryKey()
$this->assertFalse($this->adapter->hasPrimaryKey('table1', ['column1']));
}

public function testHasPrimaryKeyMultipleColumns()
{
$table = new Table('table1', ['id' => false, 'primary_key' => ['column1', 'column2', 'column3']], $this->adapter);
$table
->addColumn('column1', 'integer')
->addColumn('column2', 'integer')
->addColumn('column3', 'integer')
->save();

$this->assertFalse($table->hasPrimaryKey(['column1', 'column2']));
$this->assertTrue($table->hasPrimaryKey(['column1', 'column2', 'column3']));
}

public function testAddComment()
{
$table = new Table('table1', [], $this->adapter);
Expand Down
13 changes: 13 additions & 0 deletions tests/Phinx/Db/Adapter/PostgresAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,19 @@ public function testDropPrimaryKey()
$this->assertFalse($this->adapter->hasPrimaryKey('table1', ['column1']));
}

public function testHasPrimaryKeyMultipleColumns()
{
$table = new Table('table1', ['id' => false, 'primary_key' => ['column1', 'column2', 'column3']], $this->adapter);
$table
->addColumn('column1', 'integer')
->addColumn('column2', 'integer')
->addColumn('column3', 'integer')
->save();

$this->assertFalse($table->hasPrimaryKey(['column1', 'column2']));
$this->assertTrue($table->hasPrimaryKey(['column1', 'column2', 'column3']));
}

public function testAddComment()
{
$table = new Table('table1', [], $this->adapter);
Expand Down
13 changes: 13 additions & 0 deletions tests/Phinx/Db/Adapter/SQLiteAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,19 @@ public function testDropPrimaryKey()
$this->assertFalse($this->adapter->hasPrimaryKey('table1', ['column1']));
}

public function testHasPrimaryKeyMultipleColumns()
{
$table = new Table('table1', ['id' => false, 'primary_key' => ['column1', 'column2', 'column3']], $this->adapter);
$table
->addColumn('column1', 'integer')
->addColumn('column2', 'integer')
->addColumn('column3', 'integer')
->save();

$this->assertFalse($table->hasPrimaryKey(['column1', 'column2']));
$this->assertTrue($table->hasPrimaryKey(['column1', 'column2', 'column3']));
}

public function testAddMultipleColumnPrimaryKeyFails()
{
$table = new Table('table1', [], $this->adapter);
Expand Down
13 changes: 13 additions & 0 deletions tests/Phinx/Db/Adapter/SqlServerAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,19 @@ public function testDropPrimaryKey()
$this->assertFalse($this->adapter->hasPrimaryKey('table1', ['column1']));
}

public function testHasPrimaryKeyMultipleColumns()
{
$table = new Table('table1', ['id' => false, 'primary_key' => ['column1', 'column2', 'column3']], $this->adapter);
$table
->addColumn('column1', 'integer')
->addColumn('column2', 'integer')
->addColumn('column3', 'integer')
->save();

$this->assertFalse($table->hasPrimaryKey(['column1', 'column2']));
$this->assertTrue($table->hasPrimaryKey(['column1', 'column2', 'column3']));
}

public function testChangeCommentFails()
{
$table = new Table('table1', [], $this->adapter);
Expand Down

0 comments on commit 3358d0c

Please sign in to comment.