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

orchestral / testbench-core / 11778152077

11 Nov 2024 12:04PM UTC coverage: 91.224% (+0.01%) from 91.213%
11778152077

push

github

crynobone
Merge branch '7.x' into 8.x

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

5 of 5 new or added lines in 3 files covered. (100.0%)

2 existing lines in 2 files now uncovered.

1341 of 1470 relevant lines covered (91.22%)

63.88 hits per line

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

87.5
/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
        $databasePath = $this->laravel->databasePath();
2✔
33

34
        (new Actions\DeleteFiles(
2✔
35
            filesystem: $filesystem,
2✔
36
            components: $this->components,
2✔
37
            workingPath: $this->laravel->basePath(),
2✔
38
        ))->handle(
2✔
39
            match ($this->option('all')) {
2✔
40
                true => [...$filesystem->glob(join_paths($databasePath, '*.sqlite'))],
×
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

© 2026 Coveralls, Inc