Skip to content

Commit 909bc44

Browse files
committedAug 27, 2024··
Fix tests
1 parent ea6d6ad commit 909bc44

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed
 

‎composer.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
],
1111
"require": {
1212
"php": "^8.1",
13-
"doctrine/dbal": "^3.7 || ^4.0",
13+
"doctrine/dbal": "^3.7",
1414
"laravel/framework": "^10.2"
1515
},
1616
"require-dev": {
17-
"interaction-design-foundation/coding-standard": "^0.3",
17+
"interaction-design-foundation/coding-standard": "0.*",
18+
"orchestra/testbench": "^8.0",
1819
"phpunit/phpunit": "^10.1 || ^11.0"
1920
},
2021
"minimum-stability": "dev",
@@ -26,7 +27,7 @@
2627
},
2728
"autoload-dev": {
2829
"psr-4": {
29-
"InteractionDesignFoundation\\LaravelDatabaseToolkit\\Tests\\": "tests/"
30+
"Tests\\": "tests/"
3031
}
3132
},
3233
"config": {

‎tests/Console/Commands/FindRiskyDatabaseColumnsTest.php

+6-18
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
namespace Tests\Console\Commands;
44

5-
use App\Modules\Publication\Models\Quote;
5+
use Illuminate\Foundation\Testing\Concerns\InteractsWithConsole;
66
use Illuminate\Testing\PendingCommand;
77
use InteractionDesignFoundation\LaravelDatabaseToolkit\Console\Commands\FindRiskyDatabaseColumns;
88
use PHPUnit\Framework\Attributes\CoversClass;
99
use PHPUnit\Framework\Attributes\Test;
10-
use Tests\ApplicationTestCase;
11-
use Tests\Factories\Publication\QuoteFactory;
10+
use Tests\TestCase;
1211

13-
#[CoversClass(\App\Modules\Infrastructure\Console\Commands\FindRiskyDatabaseColumns::class)]
14-
final class FindRiskyDatabaseColumnsTest extends ApplicationTestCase
12+
#[CoversClass(FindRiskyDatabaseColumns::class)]
13+
final class FindRiskyDatabaseColumnsTest extends TestCase
1514
{
15+
use InteractsWithConsole;
16+
1617
#[Test]
1718
public function it_works_with_default_threshold(): void
1819
{
@@ -21,17 +22,4 @@ public function it_works_with_default_threshold(): void
2122
assert($pendingCommand instanceof PendingCommand);
2223
$pendingCommand->assertExitCode(0);
2324
}
24-
25-
#[Test]
26-
public function it_fails_on_very_low_threshold(): void
27-
{
28-
/** We can create {@see \App\Modules\Logging\Models\VisitorActivity} instances, but they are slow to create (too many indexes) */
29-
QuoteFactory::new()->createOne(['id' => 42_000]);
30-
31-
$pendingCommand = $this->artisan(FindRiskyDatabaseColumns::class, ['--threshold' => 0.001]);
32-
33-
assert($pendingCommand instanceof PendingCommand);
34-
$pendingCommand->assertExitCode(1);
35-
$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"
36-
}
3725
}

‎tests/TestCase.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Tests;
4+
5+
use InteractionDesignFoundation\LaravelDatabaseToolkit\DatabaseToolkitServiceProvider;
6+
7+
abstract class TestCase extends \Orchestra\Testbench\TestCase
8+
{
9+
/**
10+
* Load package service provider.
11+
* @param \Illuminate\Foundation\Application $app
12+
* @return list<string>
13+
*/
14+
protected function getPackageProviders($app): array
15+
{
16+
return [
17+
DatabaseToolkitServiceProvider::class,
18+
];
19+
}
20+
}

0 commit comments

Comments
 (0)
Please sign in to comment.