Skip to content

Commit e8387c2

Browse files
committed
[2386] fix other tests
1 parent 31d6705 commit e8387c2

1 file changed

Lines changed: 25 additions & 24 deletions

File tree

tests/Phinx/Db/Adapter/SqlServerAdapterTest.php

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ public function testAddColumnWithDefaultNull()
479479
}
480480
}
481481

482-
public function testAddColumnWithNotNullableNoDefault()
482+
public function testAddColumnWithNotNullableNoDefault(): void
483483
{
484484
$table = new Table('table1', [], $this->adapter);
485485
$table
@@ -488,10 +488,12 @@ public function testAddColumnWithNotNullableNoDefault()
488488

489489
$columns = $this->adapter->getColumns('table1');
490490
$this->assertCount(2, $columns);
491-
$this->assertArrayHasKey('id', $columns);
492-
$this->assertArrayHasKey('col', $columns);
493-
$this->assertFalse($columns['col']->isNull());
494-
$this->assertNull($columns['col']->getDefault());
491+
$firstColumn = $columns[0];
492+
$this->assertSame('id', $firstColumn->getName());
493+
$secondColumn = $columns[1];
494+
$this->assertSame('col', $secondColumn->getName());
495+
$this->assertFalse($secondColumn->isNull());
496+
$this->assertNull($secondColumn->getDefault());
495497
}
496498

497499
public function testAddColumnWithDefaultBool()
@@ -522,15 +524,15 @@ public function testAddColumnWithLiteralTypeAndDefault()
522524
->addColumn('checked', Literal::from('bit'), ['default' => 0])
523525
->save();
524526

525-
$column = $this->adapter->getColumns('table1')['checked'];
527+
$column = $this->adapter->getColumns('table1')[1];
526528

527529
$this->assertSame('checked', $column->getName());
528530
$this->assertSame('boolean', $column->getType());
529531
$this->assertSame(0, $column->getDefault());
530532
$this->assertTrue($column->getNull());
531533
}
532534

533-
public function testAddColumnWithCustomType()
535+
public function testAddColumnWithCustomType(): void
534536
{
535537
$this->adapter->setDataDomain([
536538
'custom' => [
@@ -549,18 +551,17 @@ public function testAddColumnWithCustomType()
549551
$this->assertTrue($this->adapter->hasTable('table1'));
550552

551553
$columns = $this->adapter->getColumns('table1');
552-
$this->assertArrayHasKey('custom', $columns);
553-
$this->assertArrayHasKey('custom_ext', $columns);
554+
$this->assertCount(3, $columns);
554555

555-
$column = $this->adapter->getColumns('table1')['custom'];
556-
$this->assertSame('custom', $column->getName());
557-
$this->assertSame('geometry', (string)$column->getType());
558-
$this->assertTrue($column->getNull());
556+
$customColumn = $columns[1];
557+
$this->assertSame('custom', $customColumn->getName());
558+
$this->assertSame('geometry', (string)$customColumn->getType());
559+
$this->assertTrue($customColumn->getNull());
559560

560-
$column = $this->adapter->getColumns('table1')['custom_ext'];
561-
$this->assertSame('custom_ext', $column->getName());
562-
$this->assertSame('geometry', (string)$column->getType());
563-
$this->assertFalse($column->getNull());
561+
$customExtColumn = $columns[2];
562+
$this->assertSame('custom_ext', $customExtColumn->getName());
563+
$this->assertSame('geometry', (string)$customExtColumn->getType());
564+
$this->assertFalse($customExtColumn->getNull());
564565
}
565566

566567
public function testRenameColumn()
@@ -632,15 +633,15 @@ public function testChangeColumnNameAndNull()
632633
}
633634
}
634635

635-
public function testChangeColumnDefaults()
636+
public function testChangeColumnDefaults(): void
636637
{
637638
$table = new Table('t', [], $this->adapter);
638639
$table->addColumn('column1', 'string', ['default' => 'test'])
639640
->save();
640641
$this->assertTrue($this->adapter->hasColumn('t', 'column1'));
641642

642643
$columns = $this->adapter->getColumns('t');
643-
$this->assertSame('test', $columns['column1']->getDefault());
644+
$this->assertSame('test', $columns[1]->getDefault());
644645

645646
$newColumn1 = new Column();
646647
$newColumn1
@@ -650,10 +651,10 @@ public function testChangeColumnDefaults()
650651
$this->assertTrue($this->adapter->hasColumn('t', 'column1'));
651652

652653
$columns = $this->adapter->getColumns('t');
653-
$this->assertSame('another test', $columns['column1']->getDefault());
654+
$this->assertSame('another test', $columns[1]->getDefault());
654655
}
655656

656-
public function testChangeColumnDefaultToNull()
657+
public function testChangeColumnDefaultToNull(): void
657658
{
658659
$table = new Table('t', [], $this->adapter);
659660
$table->addColumn('column1', 'string', ['null' => true, 'default' => 'test'])
@@ -664,10 +665,10 @@ public function testChangeColumnDefaultToNull()
664665
->setDefault(null);
665666
$table->changeColumn('column1', $newColumn1)->save();
666667
$columns = $this->adapter->getColumns('t');
667-
$this->assertNull($columns['column1']->getDefault());
668+
$this->assertNull($columns[1]->getDefault());
668669
}
669670

670-
public function testChangeColumnDefaultToZero()
671+
public function testChangeColumnDefaultToZero(): void
671672
{
672673
$table = new Table('t', [], $this->adapter);
673674
$table->addColumn('column1', 'integer')
@@ -678,7 +679,7 @@ public function testChangeColumnDefaultToZero()
678679
->setDefault(0);
679680
$table->changeColumn('column1', $newColumn1)->save();
680681
$columns = $this->adapter->getColumns('t');
681-
$this->assertSame(0, $columns['column1']->getDefault());
682+
$this->assertSame(0, $columns[1]->getDefault());
682683
}
683684

684685
public function testDropColumn()

0 commit comments

Comments
 (0)