Skip to content

Commit

Permalink
Test foreign key with null name
Browse files Browse the repository at this point in the history
  • Loading branch information
kitloong committed Aug 6, 2024
1 parent 8b35752 commit ad96b89
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/Unit/Migration/Generator/ForeignKeyGeneratorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace KitLoong\MigrationsGenerator\Tests\Unit\Migration\Generator;

use KitLoong\MigrationsGenerator\Database\Models\SQLite\SQLiteForeignKey;
use KitLoong\MigrationsGenerator\Enum\Migrations\Method\Foreign;
use KitLoong\MigrationsGenerator\Migration\Generator\ForeignKeyGenerator;
use KitLoong\MigrationsGenerator\Setting;
use KitLoong\MigrationsGenerator\Tests\TestCase;

class ForeignKeyGeneratorTest extends TestCase
{
public function testGenerateDropWithNullName(): void
{
$setting = app(Setting::class);
$setting->setIgnoreForeignKeyNames(false);

$foreignKeyGenerator = app(ForeignKeyGenerator::class);

$method = $foreignKeyGenerator->generateDrop(new SQLiteForeignKey('table', [
'name' => null,
'columns' => ['column'],
'foreign_schema' => null,
'foreign_table' => 'foreign_table',
'foreign_columns' => ['foreign_column'],
'on_update' => 'on_update',
'on_delete' => 'on_delete',
]));

$this->assertSame($method->getName(), Foreign::DROP_FOREIGN);
$this->assertEmpty($method->getValues());
}
}

0 comments on commit ad96b89

Please sign in to comment.