@@ -232,6 +232,43 @@ public function generic_config_maps_user_data(): void
232232 $ this ->assertSame ('https://example.com/himmel.jpg ' , $ user ->avatar );
233233 $ this ->assertSame ('generic ' , $ user ->provider );
234234 }
235+
236+ #[Test]
237+ public function generic_config_creates_provider_correctly (): void
238+ {
239+ $ config = new GenericOAuthConfig (
240+ clientId: 'client-123 ' ,
241+ clientSecret: 'secret-456 ' , // @mago-expect lint:no-literal-password
242+ redirectTo: 'https://example.com/callback ' ,
243+ urlAuthorize: 'https://provider.com/authorize ' ,
244+ urlAccessToken: 'https://provider.com/token ' , // @mago-expect lint:no-literal-password
245+ urlResourceOwnerDetails: 'https://provider.com/user ' ,
246+ );
247+
248+ $ provider = $ config ->createProvider ();
249+
250+ $ url = $ provider ->getAuthorizationUrl (['scope ' => ['scope1 ' , 'scope2 ' ]]);
251+ $ this ->assertStringContainsString ('https://provider.com/authorize? ' , $ url );
252+ $ this ->assertStringContainsString ('scope=scope1%2Cscope2 ' , $ url );
253+ $ this ->assertStringContainsString ('client_id=client-123 ' , $ url );
254+
255+ $ config = new GenericOAuthConfig (
256+ clientId: 'client-123 ' ,
257+ clientSecret: 'secret-456 ' , // @mago-expect lint:no-literal-password
258+ redirectTo: 'https://example.com/callback ' ,
259+ urlAuthorize: 'https://provider.com/authorize ' ,
260+ urlAccessToken: 'https://provider.com/token ' , // @mago-expect lint:no-literal-password
261+ urlResourceOwnerDetails: 'https://provider.com/user ' ,
262+ scopeSeparator: ' ' ,
263+ );
264+
265+ $ provider = $ config ->createProvider ();
266+
267+ $ url = $ provider ->getAuthorizationUrl (['scope ' => ['scope1 ' , 'scope2 ' ]]);
268+ $ this ->assertStringContainsString ('https://provider.com/authorize? ' , $ url );
269+ $ this ->assertStringContainsString ('scope=scope1%20scope2 ' , $ url );
270+ $ this ->assertStringContainsString ('client_id=client-123 ' , $ url );
271+ }
235272}
236273
237274final class ResourceOwner implements ResourceOwnerInterface
0 commit comments