From 11ba049295958cfce3d709ff5f13d6a8ea1af1f8 Mon Sep 17 00:00:00 2001 From: GTS-MEGHNI Date: Fri, 16 Oct 2026 17:36:31 +0100 Subject: [PATCH] test: read the embed provider list even when parallel workers inherit it CI copies .env.example, which sets EMBEDS_PROVIDERS to an empty string, and runs the tests in parallel. The workers inherit that value from the parent process, and Laravel's env repository never overwrites a variable that is already set, so the test's own value was ignored and the provider list came back empty. The test now sets the variable through a repository that can overwrite it, and puts the original value back afterwards. Co-Authored-By: Claude Opus 5.5 --- tests/Unit/Services/EmbedsTest.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/Unit/Services/EmbedsTest.php b/tests/Unit/Services/EmbedsTest.php index d46af73a8..8ea5f3591 100644 --- a/tests/Unit/Services/EmbedsTest.php +++ b/tests/Unit/Services/EmbedsTest.php @@ -7,7 +7,7 @@ use App\Enums\EmbedKind; use App\Services\EmbedProviders\YouTube; use App\Services\Embeds; -use Illuminate\Support\Env; +use Dotenv\Repository\RepositoryBuilder; use Uri\WhatWg\Url; it('embeds links to a provider', function (): void { @@ -63,9 +63,16 @@ public function embed(Url $url): Embed }); it('reads the provider list from the environment', function (): void { - Env::getRepository()->set('EMBEDS_PROVIDERS', ' youtube, ,spotify '); - $config = require config_path('embeds.php'); - Env::getRepository()->clear('EMBEDS_PROVIDERS'); + // Parallel workers inherit EMBEDS_PROVIDERS from .env, and Laravel's repository never overwrites a variable that is already set. + $repository = RepositoryBuilder::createWithDefaultAdapters()->make(); + $original = $repository->get('EMBEDS_PROVIDERS'); + + try { + $repository->set('EMBEDS_PROVIDERS', ' youtube, ,spotify '); + $config = require config_path('embeds.php'); + } finally { + $original === null ? $repository->clear('EMBEDS_PROVIDERS') : $repository->set('EMBEDS_PROVIDERS', $original); + } expect($config['only'])->toBe(['youtube', 'spotify']); });