|
4 | 4 | namespace Test\Phinx\Db\Adapter;
|
5 | 5 |
|
6 | 6 | use PDOException;
|
| 7 | +use Phinx\Config\FeatureFlags; |
7 | 8 | use Phinx\Db\Adapter\AdapterInterface;
|
8 | 9 | use Phinx\Db\Adapter\MysqlAdapter;
|
9 | 10 | use Phinx\Util\Literal;
|
@@ -156,6 +157,11 @@ public function testCreateTable()
|
156 | 157 | $this->assertTrue($this->adapter->hasColumn('ntable', 'realname'));
|
157 | 158 | $this->assertTrue($this->adapter->hasColumn('ntable', 'email'));
|
158 | 159 | $this->assertFalse($this->adapter->hasColumn('ntable', 'address'));
|
| 160 | + |
| 161 | + $columns = $this->adapter->getColumns('ntable'); |
| 162 | + $this->assertCount(3, $columns); |
| 163 | + $this->assertSame('id', $columns[0]->getName()); |
| 164 | + $this->assertFalse($columns[0]->isSigned()); |
159 | 165 | }
|
160 | 166 |
|
161 | 167 | public function testCreateTableWithComment()
|
@@ -421,6 +427,25 @@ public function testCreateTableWithLatin1Collate()
|
421 | 427 | $this->assertEquals('latin1_general_ci', $row['Collation']);
|
422 | 428 | }
|
423 | 429 |
|
| 430 | + public function testCreateTableWithSignedPK() |
| 431 | + { |
| 432 | + $table = new \Phinx\Db\Table('ntable', ['signed' => true], $this->adapter); |
| 433 | + $table->addColumn('realname', 'string') |
| 434 | + ->addColumn('email', 'integer') |
| 435 | + ->save(); |
| 436 | + $this->assertTrue($this->adapter->hasTable('ntable')); |
| 437 | + $this->assertTrue($this->adapter->hasColumn('ntable', 'id')); |
| 438 | + $this->assertTrue($this->adapter->hasColumn('ntable', 'realname')); |
| 439 | + $this->assertTrue($this->adapter->hasColumn('ntable', 'email')); |
| 440 | + $this->assertFalse($this->adapter->hasColumn('ntable', 'address')); |
| 441 | + $column_definitions = $this->adapter->getColumns('ntable'); |
| 442 | + foreach ($column_definitions as $column_definition) { |
| 443 | + if ($column_definition->getName() === 'id') { |
| 444 | + $this->assertTrue($column_definition->getSigned()); |
| 445 | + } |
| 446 | + } |
| 447 | + } |
| 448 | + |
424 | 449 | public function testCreateTableWithUnsignedPK()
|
425 | 450 | {
|
426 | 451 | $table = new \Phinx\Db\Table('ntable', ['signed' => false], $this->adapter);
|
@@ -459,6 +484,24 @@ public function testCreateTableWithUnsignedNamedPK()
|
459 | 484 | $this->assertFalse($this->adapter->hasColumn('ntable', 'address'));
|
460 | 485 | }
|
461 | 486 |
|
| 487 | + /** |
| 488 | + * @runInSeparateProcess |
| 489 | + */ |
| 490 | + public function testUnsignedPksFeatureFlag() |
| 491 | + { |
| 492 | + $this->adapter->connect(); |
| 493 | + |
| 494 | + FeatureFlags::$unsignedPrimaryKeys = false; |
| 495 | + |
| 496 | + $table = new \Phinx\Db\Table('table1', [], $this->adapter); |
| 497 | + $table->create(); |
| 498 | + |
| 499 | + $columns = $this->adapter->getColumns('table1'); |
| 500 | + $this->assertCount(1, $columns); |
| 501 | + $this->assertSame('id', $columns[0]->getName()); |
| 502 | + $this->assertTrue($columns[0]->getSigned()); |
| 503 | + } |
| 504 | + |
462 | 505 | public function testCreateTableWithLimitPK()
|
463 | 506 | {
|
464 | 507 | $table = new \Phinx\Db\Table('ntable', ['id' => 'id', 'limit' => 4], $this->adapter);
|
|
0 commit comments