diff --git a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php index 1565a3ca61..36b83bf55f 100644 --- a/tests/Phinx/Db/Adapter/MysqlAdapterTest.php +++ b/tests/Phinx/Db/Adapter/MysqlAdapterTest.php @@ -293,6 +293,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); diff --git a/tests/Phinx/Db/Adapter/PostgresAdapterTest.php b/tests/Phinx/Db/Adapter/PostgresAdapterTest.php index adecbf78ab..78c3910e48 100644 --- a/tests/Phinx/Db/Adapter/PostgresAdapterTest.php +++ b/tests/Phinx/Db/Adapter/PostgresAdapterTest.php @@ -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); @@ -1266,6 +1300,7 @@ public function testGetPhinxType() $this->assertEquals('datetime', $this->adapter->getPhinxType('timestamp without time zone')); $this->assertEquals('uuid', $this->adapter->getPhinxType('uuid')); + $this->assertEquals('binaryuuid', $this->adapter->getPhinxType('binaryuuid')); $this->assertEquals('interval', $this->adapter->getPhinxType('interval')); } diff --git a/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php b/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php index 961b365cae..d5792eec3d 100644 --- a/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php +++ b/tests/Phinx/Db/Adapter/SQLiteAdapterTest.php @@ -201,6 +201,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); @@ -1638,6 +1672,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, ];