• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

orchestral / testbench-core / 12324437332

13 Dec 2024 11:13PM UTC coverage: 91.777% (-0.5%) from 92.296%
12324437332

Pull #278

github

web-flow
Merge 82ecf708a into b1b7dd073
Pull Request #278: [7.x] Fixes database seeding using `WithWorkbench` and `RefreshDatabase`

6 of 14 new or added lines in 1 file covered. (42.86%)

25 existing lines in 8 files now uncovered.

1250 of 1362 relevant lines covered (91.78%)

64.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.75
/src/Foundation/Console/DropSqliteDbCommand.php
1
<?php
2

3
namespace Orchestra\Testbench\Foundation\Console;
4

5
use Illuminate\Console\Command;
6
use Illuminate\Filesystem\Filesystem;
7
use Illuminate\Support\Str;
8
use Symfony\Component\Console\Attribute\AsCommand;
9

10
use function Orchestra\Testbench\join_paths;
11

12
#[AsCommand(name: 'package:drop-sqlite-db', description: 'Drop sqlite database file')]
13
class DropSqliteDbCommand extends Command
14
{
15
    /**
16
     * The name and signature of the console command.
17
     *
18
     * @var string
19
     */
20
    protected $signature = 'package:drop-sqlite-db
21
                                {--database=database.sqlite : Set the database name}
22
                                {--all : Delete all SQLite databases}';
23

24
    /**
25
     * Execute the console command.
26
     *
27
     * @param  \Illuminate\Filesystem\Filesystem  $filesystem
28
     * @return int
29
     */
30
    public function handle(Filesystem $filesystem)
31
    {
32
        $workingPath = $this->laravel->basePath();
2✔
33
        $databasePath = $this->laravel->databasePath();
2✔
34

35
        (new Actions\DeleteFiles(
2✔
36
            filesystem: $filesystem,
2✔
37
            components: $this->components,
2✔
38
        ))->handle(
2✔
39
            match ($this->option('all')) {
2✔
40
                true => [...$filesystem->glob(join_paths($databasePath, '*.sqlite'))],
2✔
41
                default => [join_paths($databasePath, $this->databaseName())],
2✔
42
            }
2✔
43
        );
2✔
44

45
        return Command::SUCCESS;
2✔
46
    }
47

48
    /**
49
     * Resolve the database name.
50
     *
51
     * @return string
52
     */
53
    protected function databaseName(): string
54
    {
55
        /** @var string|null $database */
56
        $database = $this->option('database');
2✔
57

58
        if (empty($database)) {
2✔
UNCOV
59
            $database = 'database';
×
60
        }
61

62
        return \sprintf('%s.sqlite', Str::before((string) $database, '.sqlite'));
2✔
63
    }
64
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc