'version'], ['value' => '1.2.3']); $exitCode = Artisan::call('version:fetch'); expect($exitCode)->toBe(0); $build = Setting::where('key', 'build')->value('value'); expect(is_numeric($build))->toBeTrue(); }); }); it('fails when build count cannot be resolved', function (): void { withComposerBackupForFetch(function (): void { $GLOBALS['version_fetch_path'] = getenv('PATH') ?: ''; putenv('PATH=/nope'); $_ENV['PATH'] = '/nope'; $_SERVER['PATH'] = '/nope'; Setting::updateOrCreate(['key' => 'version'], ['value' => '1.2.3']); $exitCode = Artisan::call('version:fetch'); expect($exitCode)->toBe(1); }); }); it('fails when composer.json cannot be decoded', function (): void { withComposerBackupForFetch(function (string $path): void { file_put_contents($path, 'not-json'); Setting::updateOrCreate(['key' => 'version'], ['value' => '1.2.3']); $exitCode = Artisan::call('version:fetch'); expect($exitCode)->toBe(1); }); }); it('fails when composer.json is not readable', function (): void { withComposerBackupForFetch(function (string $path): void { chmod($path, 0000); Setting::updateOrCreate(['key' => 'version'], ['value' => '1.2.3']); $exitCode = Artisan::call('version:fetch'); expect($exitCode)->toBe(1); chmod($path, 0644); }); }); it('fails when file_get_contents returns false', function (): void { withComposerBackupForFetch(function (): void { $GLOBALS['version_fetch_file_get_contents_false'] = true; Setting::updateOrCreate(['key' => 'version'], ['value' => '1.2.3']); $exitCode = Artisan::call('version:fetch'); expect($exitCode)->toBe(1); }); }); it('fails when json_encode returns false', function (): void { withComposerBackupForFetch(function (): void { $GLOBALS['version_fetch_json_encode_false'] = true; Setting::updateOrCreate(['key' => 'version'], ['value' => '1.2.3']); $exitCode = Artisan::call('version:fetch'); expect($exitCode)->toBe(1); }); }); }