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

orchestral / testbench-core / 22208849058

20 Feb 2026 02:27AM UTC coverage: 92.447% (-0.1%) from 92.572%
22208849058

push

github

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

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

8 of 10 new or added lines in 2 files covered. (80.0%)

1 existing line in 1 file now uncovered.

1481 of 1602 relevant lines covered (92.45%)

70.96 hits per line

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

91.18
/src/Foundation/Bootstrap/LoadMigrationsFromArray.php
1
<?php
2

3
namespace Orchestra\Testbench\Foundation\Bootstrap;
4

5
use Illuminate\Contracts\Console\Kernel as ConsoleKernel;
6
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
7
use Illuminate\Contracts\Foundation\Application;
8
use Illuminate\Database\Events\DatabaseRefreshed;
9
use Illuminate\Support\Collection;
10
use Orchestra\Sidekick\Env;
11

12
use function Orchestra\Sidekick\transform_relative_path;
13
use function Orchestra\Testbench\default_migration_path;
14
use function Orchestra\Testbench\load_migration_paths;
15
use function Orchestra\Testbench\workbench;
16

17
/**
18
 * @internal
19
 */
20
final class LoadMigrationsFromArray
21
{
22
    /**
23
     * The migrations.
24
     *
25
     * @var array<int, string>|bool|string
26
     */
27
    public $migrations;
28

29
    /**
30
     * The seeders.
31
     *
32
     * @var array<int, class-string>|bool|class-string
33
     */
34
    public $seeders;
35

36
    /**
37
     * Construct a new Create Vendor Symlink bootstrapper.
38
     *
39
     * @param  array<int, string>|bool|string  $migrations
40
     * @param  array<int, class-string>|bool|class-string  $seeders
41
     */
42
    public function __construct($migrations = [], $seeders = false)
43
    {
44
        $this->migrations = $migrations;
37✔
45
        $this->seeders = $seeders;
37✔
46
    }
47

48
    /**
49
     * Bootstrap the given application.
50
     *
51
     * @param  \Illuminate\Contracts\Foundation\Application  $app
52
     * @return void
53
     */
54
    public function bootstrap(Application $app): void
55
    {
56
        if ($this->seeders !== false) {
37✔
57
            $this->bootstrapSeeders($app);
1✔
58
        }
59

60
        if ($this->migrations !== false) {
37✔
61
            $this->bootstrapMigrations($app);
34✔
62
        }
63
    }
64

65
    /**
66
     * Bootstrap seeders.
67
     *
68
     * @param  \Illuminate\Contracts\Foundation\Application  $app
69
     * @return void
70
     */
71
    protected function bootstrapSeeders(Application $app): void
72
    {
73
        $app->make(EventDispatcher::class)
1✔
74
            ->listen(DatabaseRefreshed::class, function (DatabaseRefreshed $event) use ($app) {
1✔
75
                if (\is_bool($this->seeders)) {
1✔
NEW
76
                    if ($this->seeders === true) {
×
NEW
77
                        $app->make(ConsoleKernel::class)->call('db:seed');
×
78
                    }
79

UNCOV
80
                    return;
×
81
                }
82

83
                Collection::wrap($this->seeders)
1✔
84
                    ->flatten()
1✔
85
                    ->filter(static fn ($seederClass) => ! \is_null($seederClass) && class_exists($seederClass))
1✔
86
                    ->each(static function ($seederClass) use ($app) {
1✔
87
                        $app->make(ConsoleKernel::class)->call('db:seed', [
1✔
88
                            '--class' => $seederClass,
1✔
89
                        ]);
1✔
90
                    });
1✔
91
            });
1✔
92
    }
93

94
    /**
95
     * Bootstrap migrations.
96
     *
97
     * @param  \Illuminate\Contracts\Foundation\Application  $app
98
     * @return void
99
     */
100
    protected function bootstrapMigrations(Application $app): void
101
    {
102
        $paths = Collection::wrap(
34✔
103
            ! \is_bool($this->migrations) ? $this->migrations : []
34✔
104
        )->when(
34✔
105
            $this->includesDefaultMigrations($app),
34✔
106
            static fn ($migrations) => $migrations->push(default_migration_path()),
34✔
107
        )->filter(static fn ($migration) => \is_string($migration))
34✔
108
            ->transform(static fn ($migration) => transform_relative_path($migration, $app->basePath()))
34✔
109
            ->all();
34✔
110

111
        load_migration_paths($app, $paths);
34✔
112
    }
113

114
    /**
115
     * Determine whether default migrations should be included.
116
     *
117
     * @param  \Illuminate\Contracts\Foundation\Application  $app
118
     * @return bool
119
     */
120
    protected function includesDefaultMigrations($app): bool
121
    {
122
        return
34✔
123
            workbench()['install'] === true
34✔
124
            && Env::get('TESTBENCH_WITHOUT_DEFAULT_MIGRATIONS') !== true
34✔
125
            && rescue(static fn () => is_dir(default_migration_path()), false, false);
34✔
126
    }
127
}
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