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

orchestral / testbench-core / 18191196056

02 Oct 2025 11:07AM UTC coverage: 91.929% (-0.06%) from 91.993%
18191196056

push

github

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

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

2 of 2 new or added lines in 1 file covered. (100.0%)

2 existing lines in 1 file now uncovered.

1549 of 1685 relevant lines covered (91.93%)

77.02 hits per line

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

83.78
/src/Foundation/PackageManifest.php
1
<?php
2

3
namespace Orchestra\Testbench\Foundation;
4

5
use Illuminate\Filesystem\Filesystem;
6
use Illuminate\Foundation\PackageManifest as IlluminatePackageManifest;
7
use Illuminate\Support\Arr;
8
use Illuminate\Support\Collection;
9

10
use function Orchestra\Sidekick\is_testbench_cli;
11
use function Orchestra\Testbench\package_path;
12

13
/**
14
 * @api
15
 */
16
class PackageManifest extends IlluminatePackageManifest
17
{
18
    /**
19
     * Testbench Class.
20
     *
21
     * @var \Orchestra\Testbench\Contracts\TestCase|object|null
22
     */
23
    protected $testbench;
24

25
    /**
26
     * List of required packages.
27
     *
28
     * @var array<int, string>
29
     */
30
    protected array $requiredPackages = [
31
        'laravel/dusk',
32
        'spatie/laravel-ray',
33
    ];
34

35
    /**
36
     * {@inheritDoc}
37
     *
38
     * @param  \Orchestra\Testbench\Contracts\TestCase|object|null  $testbench
39
     */
40
    public function __construct(Filesystem $files, $basePath, $manifestPath, $testbench = null)
41
    {
42
        parent::__construct($files, $basePath, $manifestPath);
194✔
43

44
        $this->setTestbench($testbench);
194✔
45
    }
46

47
    /**
48
     * Create a new package manifest instance from base.
49
     *
50
     * @param  \Illuminate\Foundation\Application  $app
51
     * @param  object|null  $testbench
52
     * @return void
53
     */
54
    public static function swap($app, $testbench = null): void
55
    {
56
        /** @var \Illuminate\Foundation\PackageManifest $base */
57
        $base = $app->make(IlluminatePackageManifest::class);
194✔
58

59
        $app->instance(
194✔
60
            IlluminatePackageManifest::class,
194✔
61
            new static(
194✔
62
                $base->files, $base->basePath, $base->manifestPath, $testbench
194✔
63
            )
194✔
64
        );
194✔
65
    }
66

67
    /**
68
     * Set Testbench instance.
69
     *
70
     * @param  object|null  $testbench
71
     * @return void
72
     */
73
    public function setTestbench($testbench): void
74
    {
75
        $this->testbench = \is_object($testbench) ? $testbench : null;
194✔
76
    }
77

78
    /**
79
     * Requires packages.
80
     *
81
     * @param  string[]  $packages
82
     * @return $this
83
     */
84
    public function requires(...$packages)
85
    {
86
        $this->requiredPackages = array_merge($this->requiredPackages, Arr::wrap($packages));
×
87

88
        return $this;
×
89
    }
90

91
    /** {@inheritDoc} */
92
    #[\Override]
93
    protected function getManifest()
94
    {
95
        $ignore = ! \is_null($this->testbench) && method_exists($this->testbench, 'ignorePackageDiscoveriesFrom')
194✔
96
                ? ($this->testbench->ignorePackageDiscoveriesFrom() ?? [])
194✔
97
                : [];
×
98

99
        $ignoreAll = \in_array('*', $ignore);
194✔
100

101
        $requires = $this->requiredPackages;
194✔
102

103
        return (new Collection(parent::getManifest()))
194✔
104
            ->reject(static fn ($configuration, $package) => ($ignoreAll && ! \in_array($package, $requires)) || \in_array($package, $ignore))
194✔
105
            ->map(static function ($configuration, $package) {
194✔
106
                foreach ($configuration['providers'] ?? [] as $provider) {
193✔
107
                    if (! class_exists($provider)) {
193✔
108
                        return null;
×
109
                    }
110
                }
111

112
                return $configuration;
193✔
113
            })->filter()->all();
194✔
114
    }
115

116
    /** {@inheritDoc} */
117
    #[\Override]
118
    protected function packagesToIgnore()
119
    {
120
        return [];
10✔
121
    }
122

123
    /**
124
     * Get all of the package names from root.
125
     *
126
     * @return array
127
     */
128
    protected function providersFromRoot(): array
129
    {
130
        $package = $this->providersFromTestbench();
10✔
131

132
        return \is_array($package) ? [
10✔
133
            $this->format($package['name']) => $package['extra']['laravel'] ?? [],
10✔
134
        ] : [];
10✔
135
    }
136

137
    /**
138
     * Get testbench root composer file.
139
     *
140
     * @return array{name: string, extra?: array{laravel?: array}}|null
141
     */
142
    protected function providersFromTestbench(): ?array
143
    {
144
        if (is_testbench_cli() && is_file($composerFile = package_path('composer.json'))) {
10✔
145
            /** @var array{name: string, extra?: array{laravel?: array}} $composer */
UNCOV
146
            $composer = $this->files->json($composerFile);
×
147

UNCOV
148
            return $composer;
×
149
        }
150

151
        return null;
10✔
152
    }
153

154
    /** {@inheritDoc} */
155
    #[\Override]
156
    protected function write(array $manifest)
157
    {
158
        parent::write(
10✔
159
            (new Collection($manifest))->merge($this->providersFromRoot())->filter()->all()
10✔
160
        );
10✔
161
    }
162
}
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