From 2ce00061b7ef7d263b7a41eb794126b64bc36f72 Mon Sep 17 00:00:00 2001 From: TheAladeen Date: Fri, 17 Jan 2025 07:35:32 +0000 Subject: [PATCH] Added 2 additional tests for GitHub driver programmatic scope merging and overwriting Introduced tests to verify correct behavior when merging scopes from config with programmatic scopes using `scopes()` and overwriting them using `setScopes()`. These ensure the driver handles scope configurations as expected. --- tests/SocialiteManagerTest.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/SocialiteManagerTest.php b/tests/SocialiteManagerTest.php index ea7317f7..ff11e674 100644 --- a/tests/SocialiteManagerTest.php +++ b/tests/SocialiteManagerTest.php @@ -51,4 +51,30 @@ public function test_it_can_instantiate_the_github_driver_with_scopes_without_ar $provider = $factory->driver('github'); $this->assertSame(['user:email'], $provider->getScopes()); } + + public function test_it_can_instantiate_the_github_driver_with_scopes_from_config_array_merged_by_programmatic_scopes_using_scopes_method() + { + $factory = $this->app->make(Factory::class); + $this->app['config']->set('services.github', [ + 'client_id' => 'github-client-id', + 'client_secret' => 'github-client-secret', + 'redirect' => 'http://your-callback-url', + 'scopes' => ['user:email'], + ]); + $provider = $factory->driver('github')->scopes(['read:user']); + $this->assertSame(['user:email', 'read:user'], $provider->getScopes()); + } + + public function test_it_can_instantiate_the_github_driver_with_scopes_from_config_array_overwritten_by_programmatic_scopes_using_set_scopes_method() + { + $factory = $this->app->make(Factory::class); + $this->app['config']->set('services.github', [ + 'client_id' => 'github-client-id', + 'client_secret' => 'github-client-secret', + 'redirect' => 'http://your-callback-url', + 'scopes' => ['user:email'], + ]); + $provider = $factory->driver('github')->setScopes(['read:user']); + $this->assertSame(['read:user'], $provider->getScopes()); + } }