Skip to content

Commit

Permalink
Merge tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kitloong committed Aug 4, 2024
1 parent 5e2ca00 commit 2c29c99
Showing 1 changed file with 12 additions and 26 deletions.
38 changes: 12 additions & 26 deletions tests/Unit/Database/Models/PgSQL/PgSQLColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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,
Expand All @@ -40,30 +42,14 @@ public function testSpatialTypeNameWithDot(): void
$this->assertSame(ColumnType::POINT, $column->getType());
}

public function testSpatialTypeNameWithoutDot(): void
/**
* @return array<string, string[]>
*/
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)'],
];
}
}

0 comments on commit 2c29c99

Please sign in to comment.