@yoeriboven it seems like there is no built-in way to do this, but you can easily extend Illuminate\Config\Repository class and add unset method which modifies protected $items property where all config values are stored:
use Illuminate\Config\Repository;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Config;
use Tests\TestCase;
class ConfigTest extends TestCase
{
/** @test */
public function unset_key()
{
app()->instance('config', new class extends Repository {
public function unset($key)
{
Arr::forget($this->items, $key);
}
});
$this->assertFalse(Config::has('test'));
Config::set('test', 'test');
$this->assertTrue(Config::has('test'));
Config::set('test', null);
$this->assertTrue(Config::has('test'));
Config::unset('test');
$this->assertFalse(Config::has('test'));
}
}
PHPUnit 8.5.2 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 181 ms, Memory: 16.00 MB
OK (1 test, 4 assertions)