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

orchestral / testbench-core / 22208433500

20 Feb 2026 02:08AM UTC coverage: 91.884% (-0.1%) from 91.993%
22208433500

push

github

web-flow
Run seeder when `testbench.yaml` configured with `seeders: true` (#388)

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

4 of 6 new or added lines in 1 file covered. (66.67%)

1 existing line in 1 file now uncovered.

1551 of 1688 relevant lines covered (91.88%)

78.65 hits per line

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

90.91
/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
     * Construct a new Create Vendor Symlink bootstrapper.
24
     *
25
     * @param  array<int, string>|bool|string  $migrations
26
     * @param  array<int, class-string>|bool|class-string  $seeders
27
     */
28
    public function __construct(
29
        public readonly array|bool|string $migrations = [],
30
        public readonly array|bool|string $seeders = false
31
    ) {
32
        //
33
    }
49✔
34

35
    /**
36
     * Bootstrap the given application.
37
     *
38
     * @param  \Illuminate\Contracts\Foundation\Application  $app
39
     * @return void
40
     */
41
    public function bootstrap(Application $app): void
42
    {
43
        if ($this->seeders !== false) {
49✔
44
            $this->bootstrapSeeders($app);
1✔
45
        }
46

47
        if ($this->migrations !== false) {
49✔
48
            $this->bootstrapMigrations($app);
46✔
49
        }
50
    }
51

52
    /**
53
     * Bootstrap seeders.
54
     *
55
     * @param  \Illuminate\Contracts\Foundation\Application  $app
56
     * @return void
57
     */
58
    protected function bootstrapSeeders(Application $app): void
59
    {
60
        $app->make(EventDispatcher::class)
1✔
61
            ->listen(DatabaseRefreshed::class, function (DatabaseRefreshed $event) use ($app) {
1✔
62
                if (\is_bool($this->seeders)) {
1✔
NEW
63
                    if ($this->seeders === true) {
×
NEW
64
                        $app->make(ConsoleKernel::class)->call('db:seed');
×
65
                    }
66

UNCOV
67
                    return;
×
68
                }
69

70
                Collection::wrap($this->seeders)
1✔
71
                    ->flatten()
1✔
72
                    ->filter(static fn ($seederClass) => ! \is_null($seederClass) && class_exists($seederClass))
1✔
73
                    ->each(static function ($seederClass) use ($app) {
1✔
74
                        $app->make(ConsoleKernel::class)->call('db:seed', [
1✔
75
                            '--class' => $seederClass,
1✔
76
                        ]);
1✔
77
                    });
1✔
78
            });
1✔
79
    }
80

81
    /**
82
     * Bootstrap migrations.
83
     *
84
     * @param  \Illuminate\Contracts\Foundation\Application  $app
85
     * @return void
86
     */
87
    protected function bootstrapMigrations(Application $app): void
88
    {
89
        $paths = Collection::wrap(
46✔
90
            ! \is_bool($this->migrations) ? $this->migrations : []
46✔
91
        )->when(
46✔
92
            $this->includesDefaultMigrations($app),
46✔
93
            static fn ($migrations) => $migrations->push(default_migration_path()),
46✔
94
        )->filter(static fn ($migration) => \is_string($migration))
46✔
95
            ->transform(static fn ($migration) => transform_relative_path($migration, $app->basePath()))
46✔
96
            ->all();
46✔
97

98
        load_migration_paths($app, $paths);
46✔
99
    }
100

101
    /**
102
     * Determine whether default migrations should be included.
103
     *
104
     * @param  \Illuminate\Contracts\Foundation\Application  $app
105
     * @return bool
106
     */
107
    protected function includesDefaultMigrations($app): bool
108
    {
109
        return
46✔
110
            workbench()['install'] === true
46✔
111
            && Env::get('TESTBENCH_WITHOUT_DEFAULT_MIGRATIONS') !== true
46✔
112
            && rescue(static fn () => is_dir(default_migration_path()), false, false);
46✔
113
    }
114
}
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