Skip to content

Commit 77be8be

Browse files
TheAladeenTheAladeen
and
TheAladeen
authored
Added 2 additional tests for GitHub driver programmatic scope merging and overwriting (#729)
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. Co-authored-by: TheAladeen <[email protected]>
1 parent b2ce47b commit 77be8be

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/SocialiteManagerTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,30 @@ public function test_it_can_instantiate_the_github_driver_with_scopes_without_ar
5151
$provider = $factory->driver('github');
5252
$this->assertSame(['user:email'], $provider->getScopes());
5353
}
54+
55+
public function test_it_can_instantiate_the_github_driver_with_scopes_from_config_array_merged_by_programmatic_scopes_using_scopes_method()
56+
{
57+
$factory = $this->app->make(Factory::class);
58+
$this->app['config']->set('services.github', [
59+
'client_id' => 'github-client-id',
60+
'client_secret' => 'github-client-secret',
61+
'redirect' => 'http://your-callback-url',
62+
'scopes' => ['user:email'],
63+
]);
64+
$provider = $factory->driver('github')->scopes(['read:user']);
65+
$this->assertSame(['user:email', 'read:user'], $provider->getScopes());
66+
}
67+
68+
public function test_it_can_instantiate_the_github_driver_with_scopes_from_config_array_overwritten_by_programmatic_scopes_using_set_scopes_method()
69+
{
70+
$factory = $this->app->make(Factory::class);
71+
$this->app['config']->set('services.github', [
72+
'client_id' => 'github-client-id',
73+
'client_secret' => 'github-client-secret',
74+
'redirect' => 'http://your-callback-url',
75+
'scopes' => ['user:email'],
76+
]);
77+
$provider = $factory->driver('github')->setScopes(['read:user']);
78+
$this->assertSame(['read:user'], $provider->getScopes());
79+
}
5480
}

0 commit comments

Comments
 (0)