From 6385f24e17d92e86c86e1e54ba78d786fcc35235 Mon Sep 17 00:00:00 2001 From: Jason McCreary Date: Mon, 4 Mar 2024 19:55:44 -0500 Subject: [PATCH] Backfill tests --- .../Foundation/FoundationApplicationTest.php | 54 +++++++++++++++++++ .../fixtures/config/broadcasting.php | 17 ++++++ tests/Foundation/fixtures/config/cache.php | 17 ++++++ tests/Foundation/fixtures/config/database.php | 17 ++++++ .../fixtures/config/filesystems.php | 17 ++++++ tests/Foundation/fixtures/config/logging.php | 17 ++++++ tests/Foundation/fixtures/config/mail.php | 17 ++++++ tests/Foundation/fixtures/config/queue.php | 17 ++++++ 8 files changed, 173 insertions(+) create mode 100644 tests/Foundation/fixtures/config/broadcasting.php create mode 100644 tests/Foundation/fixtures/config/cache.php create mode 100644 tests/Foundation/fixtures/config/database.php create mode 100644 tests/Foundation/fixtures/config/filesystems.php create mode 100644 tests/Foundation/fixtures/config/logging.php create mode 100644 tests/Foundation/fixtures/config/mail.php create mode 100644 tests/Foundation/fixtures/config/queue.php diff --git a/tests/Foundation/FoundationApplicationTest.php b/tests/Foundation/FoundationApplicationTest.php index f23dc801f33d..d5aba462c2bf 100755 --- a/tests/Foundation/FoundationApplicationTest.php +++ b/tests/Foundation/FoundationApplicationTest.php @@ -524,6 +524,60 @@ public function testUseConfigPath(): void $this->assertSame('bar', $app->make('config')->get('app.foo')); } + + public function testMergingConfig(): void + { + $app = new Application; + $app->useConfigPath(__DIR__.'/fixtures/config'); + $app->bootstrapWith([\Illuminate\Foundation\Bootstrap\LoadConfiguration::class]); + + $config = $app->make('config'); + + $this->assertSame('UTC', $config->get('app.timezone')); + $this->assertSame('bar', $config->get('app.foo')); + + $this->assertSame('overwrite', $config->get('broadcasting.default')); + $this->assertSame('broadcasting', $config->get('broadcasting.custom_option')); + $this->assertIsArray($config->get('broadcasting.connections.pusher')); + $this->assertSame(['overwrite' => true], $config->get('broadcasting.connections.reverb')); + $this->assertSame(['merge' => true], $config->get('broadcasting.connections.new')); + + $this->assertSame('overwrite', $config->get('cache.default')); + $this->assertSame('cache', $config->get('cache.custom_option')); + $this->assertIsArray($config->get('cache.stores.database')); + $this->assertSame(['overwrite' => true], $config->get('cache.stores.array')); + $this->assertSame(['merge' => true], $config->get('cache.stores.new')); + + $this->assertSame('overwrite', $config->get('database.default')); + $this->assertSame('database', $config->get('database.custom_option')); + $this->assertIsArray($config->get('database.connections.pgsql')); + $this->assertSame(['overwrite' => true], $config->get('database.connections.mysql')); + $this->assertSame(['merge' => true], $config->get('database.connections.new')); + + $this->assertSame('overwrite', $config->get('filesystems.default')); + $this->assertSame('filesystems', $config->get('filesystems.custom_option')); + $this->assertIsArray($config->get('filesystems.disks.s3')); + $this->assertSame(['overwrite' => true], $config->get('filesystems.disks.local')); + $this->assertSame(['merge' => true], $config->get('filesystems.disks.new')); + + $this->assertSame('overwrite', $config->get('logging.default')); + $this->assertSame('logging', $config->get('logging.custom_option')); + $this->assertIsArray($config->get('logging.channels.single')); + $this->assertSame(['overwrite' => true], $config->get('logging.channels.stack')); + $this->assertSame(['merge' => true], $config->get('logging.channels.new')); + + $this->assertSame('overwrite', $config->get('mail.default')); + $this->assertSame('mail', $config->get('mail.custom_option')); + $this->assertIsArray($config->get('mail.mailers.ses')); + $this->assertSame(['overwrite' => true], $config->get('mail.mailers.smtp')); + $this->assertSame(['merge' => true], $config->get('mail.mailers.new')); + + $this->assertSame('overwrite', $config->get('queue.default')); + $this->assertSame('queue', $config->get('queue.custom_option')); + $this->assertIsArray($config->get('queue.connections.redis')); + $this->assertSame(['overwrite' => true], $config->get('queue.connections.database')); + $this->assertSame(['merge' => true], $config->get('queue.connections.new')); + } } class ApplicationBasicServiceProviderStub extends ServiceProvider diff --git a/tests/Foundation/fixtures/config/broadcasting.php b/tests/Foundation/fixtures/config/broadcasting.php new file mode 100644 index 000000000000..64e9feb8b69a --- /dev/null +++ b/tests/Foundation/fixtures/config/broadcasting.php @@ -0,0 +1,17 @@ + 'broadcasting', + + 'default' => 'overwrite', + + 'connections' => [ + 'reverb' => [ + 'overwrite' => true, + ], + + 'new' => [ + 'merge' => true, + ], + ], +]; diff --git a/tests/Foundation/fixtures/config/cache.php b/tests/Foundation/fixtures/config/cache.php new file mode 100644 index 000000000000..1cf018a7a2f2 --- /dev/null +++ b/tests/Foundation/fixtures/config/cache.php @@ -0,0 +1,17 @@ + 'cache', + + 'default' => 'overwrite', + + 'stores' => [ + 'array' => [ + 'overwrite' => true, + ], + + 'new' => [ + 'merge' => true, + ], + ], +]; diff --git a/tests/Foundation/fixtures/config/database.php b/tests/Foundation/fixtures/config/database.php new file mode 100644 index 000000000000..39cd53129aa2 --- /dev/null +++ b/tests/Foundation/fixtures/config/database.php @@ -0,0 +1,17 @@ + 'database', + + 'default' => 'overwrite', + + 'connections' => [ + 'mysql' => [ + 'overwrite' => true, + ], + + 'new' => [ + 'merge' => true, + ], + ], +]; diff --git a/tests/Foundation/fixtures/config/filesystems.php b/tests/Foundation/fixtures/config/filesystems.php new file mode 100644 index 000000000000..841d49bd0171 --- /dev/null +++ b/tests/Foundation/fixtures/config/filesystems.php @@ -0,0 +1,17 @@ + 'filesystems', + + 'default' => 'overwrite', + + 'disks' => [ + 'local' => [ + 'overwrite' => true, + ], + + 'new' => [ + 'merge' => true, + ], + ], +]; diff --git a/tests/Foundation/fixtures/config/logging.php b/tests/Foundation/fixtures/config/logging.php new file mode 100644 index 000000000000..2d2c82387335 --- /dev/null +++ b/tests/Foundation/fixtures/config/logging.php @@ -0,0 +1,17 @@ + 'logging', + + 'default' => 'overwrite', + + 'channels' => [ + 'stack' => [ + 'overwrite' => true, + ], + + 'new' => [ + 'merge' => true, + ], + ], +]; diff --git a/tests/Foundation/fixtures/config/mail.php b/tests/Foundation/fixtures/config/mail.php new file mode 100644 index 000000000000..4a815395eca2 --- /dev/null +++ b/tests/Foundation/fixtures/config/mail.php @@ -0,0 +1,17 @@ + 'mail', + + 'default' => 'overwrite', + + 'mailers' => [ + 'smtp' => [ + 'overwrite' => true, + ], + + 'new' => [ + 'merge' => true, + ], + ], +]; diff --git a/tests/Foundation/fixtures/config/queue.php b/tests/Foundation/fixtures/config/queue.php new file mode 100644 index 000000000000..059eba794dd7 --- /dev/null +++ b/tests/Foundation/fixtures/config/queue.php @@ -0,0 +1,17 @@ + 'queue', + + 'default' => 'overwrite', + + 'connections' => [ + 'database' => [ + 'overwrite' => true, + ], + + 'new' => [ + 'merge' => true, + ], + ], +];