Skip to content

Commit

Permalink
Move data provider
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Sep 23, 2024
1 parent acbff3a commit 21ea400
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
16 changes: 2 additions & 14 deletions tests/Db/Command/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Schema\Builder\ColumnInterface;
use Yiisoft\Db\Tests\AbstractCommandTest;
use Yiisoft\Db\Tests\Provider\CommandProvider;
use Yiisoft\Db\Tests\Support\Assert;
use Yiisoft\Db\Tests\Support\DbHelper;
use Yiisoft\Db\Tests\Support\TestTrait;
Expand Down Expand Up @@ -460,20 +461,7 @@ public function testDropView(): void
);
}

public static function dataDropTable(): iterable
{
yield ['DROP TABLE [[table]]', null, null];
yield ['DROP TABLE IF EXISTS [[table]]', true, null];
yield ['DROP TABLE [[table]]', false, null];
yield ['DROP TABLE [[table]] CASCADE', null, true];
yield ['DROP TABLE [[table]]', null, false];
yield ['DROP TABLE [[table]]', false, false];
yield ['DROP TABLE IF EXISTS [[table]] CASCADE', true, true];
yield ['DROP TABLE IF EXISTS [[table]]', true, false];
yield ['DROP TABLE [[table]] CASCADE', false, true];
}

#[DataProvider('dataDropTable')]
#[DataProvider(CommandProvider::class.'::dropTable')]
public function testDropTable(string $expected, ?bool $ifExists, ?bool $cascade): void
{
$db = $this->getConnection();
Expand Down
13 changes: 13 additions & 0 deletions tests/Provider/CommandProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -926,4 +926,17 @@ public static function columnTypes(): array
[new Column('string(100)')],
];
}

public static function dropTable(): iterable
{
yield ['DROP TABLE [[table]]', null, null];
yield ['DROP TABLE IF EXISTS [[table]]', true, null];
yield ['DROP TABLE [[table]]', false, null];
yield ['DROP TABLE [[table]] CASCADE', null, true];
yield ['DROP TABLE [[table]]', null, false];
yield ['DROP TABLE [[table]]', false, false];
yield ['DROP TABLE IF EXISTS [[table]] CASCADE', true, true];
yield ['DROP TABLE IF EXISTS [[table]]', true, false];
yield ['DROP TABLE [[table]] CASCADE', false, true];
}
}

0 comments on commit 21ea400

Please sign in to comment.