Skip to content

Commit 686e05f

Browse files
committed
chore: add sqlite in database connection
1 parent 7889698 commit 686e05f

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

src/Concerns/InteractsWithConsole.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
use Hyperf\Database\Commands\Seeders\SeedCommand;
1010
use Hyperf\Database\Commands\Migrations\RollbackCommand;
1111
use Symfony\Component\Console\Input\ArrayInput;
12+
use Symfony\Component\Console\Input\StringInput;
1213
use Symfony\Component\Console\Output\BufferedOutput;
1314

1415
trait InteractsWithConsole
1516
{
1617
public function fresh(): string
1718
{
18-
$input = new ArrayInput([]);
19+
$input = new StringInput('--database=sqlite');
1920
$output = new BufferedOutput();
2021

2122
ApplicationContext::getContainer()->get(FreshCommand::class)->run($input, $output);
@@ -25,7 +26,7 @@ public function fresh(): string
2526

2627
public function rollback(): string
2728
{
28-
$input = new ArrayInput([]);
29+
$input = new StringInput('--database=sqlite');
2930
$output = new BufferedOutput();
3031

3132
ApplicationContext::getContainer()->get(RollbackCommand::class)->run($input, $output);
@@ -35,7 +36,7 @@ public function rollback(): string
3536

3637
public function seed(): string
3738
{
38-
$input = new ArrayInput([]);
39+
$input = new StringInput('--database=sqlite');
3940
$output = new BufferedOutput();
4041

4142
ApplicationContext::getContainer()->get(SeedCommand::class)->run($input, $output);

src/Concerns/InteractsWithDatabase.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,17 @@
2020

2121
trait InteractsWithDatabase
2222
{
23-
24-
protected function assertDatabaseCount(string $table, int $count, ?string $connection = null): void
23+
protected function assertDatabaseCount(string $table, int $count, ?string $connection = 'sqlite'): void
2524
{
2625
$this->assertEquals($count, $this->getConnection($connection)->table($table)->count());
2726
}
2827

29-
protected function assertDatabaseHas(string $table, array $data, ?string $connection = null): void
28+
protected function assertDatabaseHas(string $table, array $data, ?string $connection = 'sqlite'): void
3029
{
3130
$this->assertThat($data, new HasInDatabase($this->getConnection($connection), $table));
3231
}
3332

34-
protected function assertDatabaseMissing(string $table, array $data, ?string $connection = null): void
33+
protected function assertDatabaseMissing(string $table, array $data, ?string $connection = 'sqlite'): void
3534
{
3635
$this->assertThat($data, new LogicalNot(new HasInDatabase($this->getConnection($connection), $table)));
3736
}

src/DatabaseMigrations.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,10 @@
44

55
namespace Hyperf\Testing;
66

7-
use Hyperf\Context\ApplicationContext;
8-
use Hyperf\Contract\ConfigInterface;
9-
107
trait DatabaseMigrations
118
{
12-
protected array $database = [
13-
'driver' => 'sqlite',
14-
'database' => ':memory:',
15-
];
16-
179
public function setUpDatabaseMigrations(): void
1810
{
19-
ApplicationContext::getContainer()->get(ConfigInterface::class)->set('databases.default', $this->database);
20-
2111
$this->fresh();
2212
$this->seed();
2313
}

0 commit comments

Comments
 (0)