Skip to content

Commit b9f2a49

Browse files
committed
test: isolate Composer autoload fixtures and cover null default drivers
Point PackageManifest at the temporary vendor directory so the Composer autoload failure tests no longer depend on the host's vendor directory, and cover null values for each required default driver.
1 parent f70b9ab commit b9f2a49

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

‎tests/Doctor/Feature/Diagnostics/ComposerAutoloadIsValidTest.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public function testExplainsComposerFailuresWithoutOutput(): void
133133
file_put_contents($basePath . '/composer.json', '{}');
134134
file_put_contents($basePath . '/vendor/autoload.php', '<?php');
135135

136+
$this->app->make(PackageManifest::class)->vendorPath = $basePath . '/vendor';
137+
136138
Process::fake([
137139
'*' => Process::result(exitCode: 137),
138140
]);
@@ -152,6 +154,8 @@ public function testReportsStandardOutputWhenErrorOutputIsBlank(): void
152154
file_put_contents($basePath . '/composer.json', '{}');
153155
file_put_contents($basePath . '/vendor/autoload.php', '<?php');
154156

157+
$this->app->make(PackageManifest::class)->vendorPath = $basePath . '/vendor';
158+
155159
Process::fake([
156160
'*' => Process::result(
157161
output: 'Class App\Foo does not comply with psr-4 autoloading standard.',
@@ -173,6 +177,8 @@ public function testExplainsComposerFailuresWithoutOutputOrExitCode(): void
173177
file_put_contents($basePath . '/composer.json', '{}');
174178
file_put_contents($basePath . '/vendor/autoload.php', '<?php');
175179

180+
$this->app->make(PackageManifest::class)->vendorPath = $basePath . '/vendor';
181+
176182
$result = new class(new SymfonyProcess(['composer'])) extends ProcessResult {
177183
/**
178184
* Determine if the process was successful.

‎tests/Doctor/Feature/Diagnostics/RequiredConfigurationValuesAreSetTest.php‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public function testPassesWithTheDefaultConfiguration(): void
2121
}
2222

2323
#[DataProvider('requiredDefaults')]
24-
public function testReportsBlankRequiredDefaultsInsteadOfAssumingADriver(string $key, string $feature): void
24+
public function testReportsBlankRequiredDefaultsInsteadOfAssumingADriver(string $key, string $feature, ?string $value): void
2525
{
26-
config([$key => '']);
26+
config([$key => $value]);
2727

2828
$result = (new RequiredConfigurationValuesAreSet)->check();
2929

@@ -32,15 +32,19 @@ public function testReportsBlankRequiredDefaultsInsteadOfAssumingADriver(string
3232
}
3333

3434
/**
35-
* Provide required default keys and the features that need them.
35+
* Provide required default keys, the features that need them, and unusable values.
3636
*/
3737
public static function requiredDefaults(): array
3838
{
3939
return [
40-
['broadcasting.default', 'default broadcaster'],
41-
['filesystems.default', 'default filesystem disk'],
42-
['mail.default', 'default mailer'],
43-
['queue.default', 'default queue connection'],
40+
'blank broadcaster' => ['broadcasting.default', 'default broadcaster', ''],
41+
'null broadcaster' => ['broadcasting.default', 'default broadcaster', null],
42+
'blank filesystem disk' => ['filesystems.default', 'default filesystem disk', ''],
43+
'null filesystem disk' => ['filesystems.default', 'default filesystem disk', null],
44+
'blank mailer' => ['mail.default', 'default mailer', ''],
45+
'null mailer' => ['mail.default', 'default mailer', null],
46+
'blank queue connection' => ['queue.default', 'default queue connection', ''],
47+
'null queue connection' => ['queue.default', 'default queue connection', null],
4448
];
4549
}
4650

0 commit comments

Comments
 (0)