Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
taka-oyama committed Nov 29, 2023
1 parent b8bfd79 commit 4c04616
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/Schema/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,47 @@ public function testCreateInterleavedTable(): void
$this->assertTrue($sb->hasTable(self::TABLE_NAME_RELATION_CHILD_INTERLEAVED));
}

public function test_getTables(): void
{
$conn = $this->getDefaultConnection();
$sb = $conn->getSchemaBuilder();

$sb->create(self::TABLE_NAME_CREATED, function (Blueprint $table) {
$table->uuid('id');
$table->primary('id');
});

/** @var array{ name: string, type: string } $row */
$row = Arr::first(
$sb->getTables(),
static fn (array $row): bool => $row['name'] === self::TABLE_NAME_CREATED,
);

$this->assertSame(self::TABLE_NAME_CREATED, $row['name']);
}

public function test_getColumns(): void
{
$conn = $this->getDefaultConnection();
$sb = $conn->getSchemaBuilder();

$sb->create(self::TABLE_NAME_CREATED, function (Blueprint $table) {
$table->uuid('id');
$table->primary('id');
});

$this->assertSame([
'name' => 'id',
'type_name' => 'STRING',
'type' => 'STRING(36)',
'collation' => null,
'nullable' => false,
'default' => null,
'auto_increment' => false,
'comment' => null,
], Arr::first($sb->getColumns(self::TABLE_NAME_CREATED)));
}

public function test_getAllTables(): void
{
$conn = $this->getDefaultConnection();
Expand Down

0 comments on commit 4c04616

Please sign in to comment.