Skip to content

Commit

Permalink
Added 2 additional tests for GitHub driver programmatic scope merging…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
TheAladeen authored and TheAladeen committed Jan 17, 2025
1 parent b2ce47b commit 2ce0006
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/SocialiteManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

0 comments on commit 2ce0006

Please sign in to comment.