diff --git a/tests/Unit/Database/Models/PgSQL/PgSQLColumnTest.php b/tests/Unit/Database/Models/PgSQL/PgSQLColumnTest.php index dba7c3d..029c9c9 100644 --- a/tests/Unit/Database/Models/PgSQL/PgSQLColumnTest.php +++ b/tests/Unit/Database/Models/PgSQL/PgSQLColumnTest.php @@ -8,12 +8,14 @@ use KitLoong\MigrationsGenerator\Support\CheckLaravelVersion; use KitLoong\MigrationsGenerator\Tests\TestCase; use Mockery\MockInterface; +use PHPUnit\Framework\Attributes\DataProvider; class PgSQLColumnTest extends TestCase { use CheckLaravelVersion; - public function testSpatialTypeNameWithDot(): void + #[DataProvider('spatialTypeNameProvider')] + public function testSpatialTypeName(string $type): void { $this->mock(PgSQLRepository::class, static function (MockInterface $mock): void { $mock->shouldReceive('getStoredDefinition'); @@ -22,7 +24,7 @@ public function testSpatialTypeNameWithDot(): void $column = new PgSQLColumn('table', [ 'name' => 'column', 'type_name' => 'geography', - 'type' => 'extensions.geography(Point,4326)', + 'type' => $type, 'collation' => null, 'nullable' => false, 'default' => null, @@ -40,30 +42,14 @@ public function testSpatialTypeNameWithDot(): void $this->assertSame(ColumnType::POINT, $column->getType()); } - public function testSpatialTypeNameWithoutDot(): void + /** + * @return array + */ + public static function spatialTypeNameProvider(): array { - $this->mock(PgSQLRepository::class, static function (MockInterface $mock): void { - $mock->shouldReceive('getStoredDefinition'); - }); - - $column = new PgSQLColumn('table', [ - 'name' => 'column', - 'type_name' => 'geography', - 'type' => 'geography(Point,4326)', - 'collation' => null, - 'nullable' => false, - 'default' => null, - 'auto_increment' => false, - 'comment' => null, - ]); - - if ($this->atLeastLaravel11()) { - $this->assertSame(ColumnType::GEOGRAPHY, $column->getType()); - $this->assertSame('point', $column->getSpatialSubType()); - $this->assertSame(4326, $column->getSpatialSrID()); - return; - } - - $this->assertSame(ColumnType::POINT, $column->getType()); + return [ + 'with dot' => ['extensions.geography(Point,4326)'], + 'without dot' => ['geography(Point,4326)'], + ]; } }