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

orchestral / testbench-core / 21691056316

04 Feb 2026 10:35PM UTC coverage: 92.002%. Remained the same
21691056316

push

github

web-flow
PHPStan 2.1.38 compatibility (#385)

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

0 of 1 new or added line in 1 file covered. (0.0%)

1553 of 1688 relevant lines covered (92.0%)

78.77 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);
198✔
43

44
        $this->setTestbench($testbench);
198✔
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);
198✔
58

59
        $app->instance(
198✔
60
            IlluminatePackageManifest::class,
198✔
61
            new static(
198✔
62
                $base->files, $base->basePath, $base->manifestPath, $testbench
198✔
63
            )
198✔
64
        );
198✔
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;
198✔
76
    }
77

78
    /**
79
     * Requires packages.
80
     *
81
     * @param  string[]  $packages
82
     * @return $this
83
     */
84
    public function requires(...$packages)
85
    {
NEW
86
        $this->requiredPackages = array_merge($this->requiredPackages, Arr::wrap($packages)); // @phpstan-ignore assign.propertyType
×
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')
198✔
96
                ? ($this->testbench->ignorePackageDiscoveriesFrom() ?? [])
198✔
97
                : [];
×
98

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

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

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

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

116
    /** {@inheritDoc} */
117
    #[\Override]
118
    protected function packagesToIgnore()
119
    {
120
        return [];
11✔
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();
11✔
131

132
        return \is_array($package) ? [
11✔
133
            $this->format($package['name']) => $package['extra']['laravel'] ?? [],
11✔
134
        ] : [];
11✔
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'))) {
11✔
145
            /** @var array{name: string, extra?: array{laravel?: array}} $composer */
146
            $composer = $this->files->json($composerFile);
×
147

148
            return $composer;
×
149
        }
150

151
        return null;
11✔
152
    }
153

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