diff --git a/composer.json b/composer.json index f8c964b..6af00a1 100644 --- a/composer.json +++ b/composer.json @@ -10,11 +10,12 @@ ], "require": { "php": "^8.1", - "doctrine/dbal": "^3.7 || ^4.0", + "doctrine/dbal": "^3.7", "laravel/framework": "^10.2" }, "require-dev": { - "interaction-design-foundation/coding-standard": "^0.3", + "interaction-design-foundation/coding-standard": "0.*", + "orchestra/testbench": "^8.0", "phpunit/phpunit": "^10.1 || ^11.0" }, "minimum-stability": "dev", @@ -26,7 +27,7 @@ }, "autoload-dev": { "psr-4": { - "InteractionDesignFoundation\\LaravelDatabaseToolkit\\Tests\\": "tests/" + "Tests\\": "tests/" } }, "config": { diff --git a/tests/Console/Commands/FindRiskyDatabaseColumnsTest.php b/tests/Console/Commands/FindRiskyDatabaseColumnsTest.php index 62adaaa..ff46e4c 100644 --- a/tests/Console/Commands/FindRiskyDatabaseColumnsTest.php +++ b/tests/Console/Commands/FindRiskyDatabaseColumnsTest.php @@ -2,17 +2,18 @@ namespace Tests\Console\Commands; -use App\Modules\Publication\Models\Quote; +use Illuminate\Foundation\Testing\Concerns\InteractsWithConsole; use Illuminate\Testing\PendingCommand; use InteractionDesignFoundation\LaravelDatabaseToolkit\Console\Commands\FindRiskyDatabaseColumns; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Test; -use Tests\ApplicationTestCase; -use Tests\Factories\Publication\QuoteFactory; +use Tests\TestCase; -#[CoversClass(\App\Modules\Infrastructure\Console\Commands\FindRiskyDatabaseColumns::class)] -final class FindRiskyDatabaseColumnsTest extends ApplicationTestCase +#[CoversClass(FindRiskyDatabaseColumns::class)] +final class FindRiskyDatabaseColumnsTest extends TestCase { + use InteractsWithConsole; + #[Test] public function it_works_with_default_threshold(): void { @@ -21,17 +22,4 @@ public function it_works_with_default_threshold(): void assert($pendingCommand instanceof PendingCommand); $pendingCommand->assertExitCode(0); } - - #[Test] - public function it_fails_on_very_low_threshold(): void - { - /** We can create {@see \App\Modules\Logging\Models\VisitorActivity} instances, but they are slow to create (too many indexes) */ - QuoteFactory::new()->createOne(['id' => 42_000]); - - $pendingCommand = $this->artisan(FindRiskyDatabaseColumns::class, ['--threshold' => 0.001]); - - assert($pendingCommand instanceof PendingCommand); - $pendingCommand->assertExitCode(1); - $pendingCommand->expectsOutputToContain(get_table_name(Quote::class).'.id is full for '); // check line like "ixdf.quote.id is 0.0148% full (threshold for allowed usage is 0.0000001%)\n" - } } diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..912b418 --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,20 @@ + + */ + protected function getPackageProviders($app): array + { + return [ + DatabaseToolkitServiceProvider::class, + ]; + } +}