Skip to content

Commit

Permalink
wip: tweak test layout
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Jan 14, 2025
1 parent 84f7e6f commit 3db257a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/phpunit/Migration/EntityDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testGetEntityClassList_noFiles():void {
}

public function testGetEntityClassList():void {
$dir = "test/phpunit/TestProjectRoot";
$dir = "test/phpunit/01-EntityDetectorTest";
$sut = new EntityDetector();
$detected = $sut->getEntityClassList($dir);
self::assertCount(2, $detected);
Expand Down
45 changes: 44 additions & 1 deletion test/phpunit/Migration/Query/SchemaQuerySQLiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,51 @@ public function testGenerateSql():void {

$sut = new SchemaQuerySQLite($schemaTable);

$expected = <<<SQL
create table `TestTable` (
`id` int not null primary key,
`name` text null
)
SQL;

self::assertSameSQL(
$expected,
$sut->generateSql(),
);
}

public function testGenerateSql_autoIncrement():void {
$field1 = self::createMock(SchemaField::class);
$field1->method("getName")->willReturn("id");
$field1->method("getType")->willReturn("int");
$field1->method("isNullable")->willReturn(false);
$field2 = self::createMock(SchemaField::class);
$field2->method("getName")->willReturn("name");
$field2->method("getType")->willReturn("string");
$field2->method("isNullable")->willReturn(true);

$fieldList = [$field1, $field2];

$schemaTable = self::createMock(SchemaTable::class);
$schemaTable->method("getName")
->willReturn("TestTable");
$schemaTable->method("getPrimaryKey")
->willReturn($field1);

$schemaTable->method("getFieldList")
->willReturn($fieldList);

$sut = new SchemaQuerySQLite($schemaTable);

$expected = <<<SQL
create table `TestTable` (
`id` int not null primary key,
`name` text null
)
SQL;

self::assertSameSQL(
"create table `TestTable` ( `id` int not null primary key, `name` text null )",
$expected,
$sut->generateSql(),
);
}
Expand Down

0 comments on commit 3db257a

Please sign in to comment.