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

orchestral / testbench-core / 22208736462

20 Feb 2026 02:22AM UTC coverage: 92.418% (-0.1%) from 92.549%
22208736462

push

github

crynobone
fix tests

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

1414 of 1530 relevant lines covered (92.42%)

66.09 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;
36✔
45
        $this->seeders = $seeders;
36✔
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) {
36✔
57
            $this->bootstrapSeeders($app);
1✔
58
        }
59

60
        if ($this->migrations !== false) {
36✔
61
            $this->bootstrapMigrations($app);
33✔
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✔
76
                    if ($this->seeders === true) {
×
77
                        $app->make(ConsoleKernel::class)->call('db:seed');
×
78
                    }
79

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(
33✔
103
            ! \is_bool($this->migrations) ? $this->migrations : []
33✔
104
        )->when(
33✔
105
            $this->includesDefaultMigrations($app),
33✔
106
            static fn ($migrations) => $migrations->push(default_migration_path()),
33✔
107
        )->filter(static fn ($migration) => \is_string($migration))
33✔
108
            ->transform(static fn ($migration) => transform_relative_path($migration, $app->basePath()))
33✔
109
            ->all();
33✔
110

111
        load_migration_paths($app, $paths);
33✔
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
33✔
123
            workbench()['install'] === true
33✔
124
            && Env::get('TESTBENCH_WITHOUT_DEFAULT_MIGRATIONS') !== true
33✔
125
            && rescue(static fn () => is_dir(default_migration_path()), false, false);
33✔
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