Snapshot of main at 9f39a6e1e (2026-11-02)

This commit is contained in:
Ronald Huynen committed 2026-11-02 10:41:47 +01:00
commit 6ccf1792d7
2580 files changed
+1040202

No files matched your search

@@ -0,0 +1,72 @@
<?php
namespace Tests\Feature;
use Illuminate\Support\Facades\File;
use Tests\TestCase;
/**
* A platform may use its own config name (TIMEBANK_CONFIG=myorg, config/myorg.php). config:merge used
* to know only themes, timebank-default and timebank_cc, so such a config never received new keys.
* Without an .example of its own, it is merged from config/timebank-default.php.example.
*/
class ConfigMergePlatformNameTest extends TestCase
{
private string $name = 'config-merge-test-platform';
private string $path;
protected function setUp(): void
{
parent::setUp();
$this->path = base_path("config/{$this->name}.php");
config(['app.timebank_config' => $this->name]);
$this->cleanup();
}
protected function tearDown(): void
{
$this->cleanup();
parent::tearDown();
}
private function cleanup(): void
{
File::delete([$this->path, "{$this->path}.example"]);
foreach (File::glob(storage_path("config-backups/{$this->name}.php.backup.*")) as $backup) {
File::delete($backup);
}
}
public function test_a_platform_config_with_its_own_name_gets_new_keys_from_the_default_template(): void
{
File::put($this->path, "<?php\n\nreturn [\n 'own_setting' => 'kept',\n];\n");
$this->artisan('config:merge', ['file' => $this->name, '--force' => true])->assertExitCode(0);
$merged = include $this->path;
$this->assertSame('kept', $merged['own_setting']);
$this->assertSame(['App\Models\Admin', 'App\Models\Bank'], $merged['account_info']['privileged_viewer_types']);
}
public function test_all_includes_the_platform_config(): void
{
File::put($this->path, "<?php\n\nreturn [\n 'own_setting' => 'kept',\n];\n");
$this->artisan('config:merge', ['--all' => true, '--dry-run' => true])
->expectsOutputToContain("Config: {$this->name}")
->assertExitCode(0);
}
public function test_its_own_example_wins_over_the_default_template(): void
{
File::put($this->path, "<?php\n\nreturn [\n 'a' => 1,\n];\n");
File::put("{$this->path}.example", "<?php\n\nreturn [\n 'a' => 1,\n 'b' => 2,\n];\n");
$this->artisan('config:merge', ['file' => $this->name, '--force' => true])->assertExitCode(0);
$this->assertSame(['a' => 1, 'b' => 2], include $this->path);
}
}