2020
2121use OpenConext \EngineBlock \Service \Wayf \IdpSplitter ;
2222use OpenConext \EngineBlock \Service \Wayf \WayfIdp ;
23+ use OpenConext \EngineBlock \Service \Wayf \WayfSplitResult ;
2324use PHPUnit \Framework \Attributes \DataProvider ;
2425use PHPUnit \Framework \TestCase ;
2526
@@ -32,7 +33,7 @@ protected function setUp(): void
3233 $ this ->splitter = new IdpSplitter ();
3334 }
3435
35- private function split (array $ idpList , array $ preferredEntityIds ): array
36+ private function split (array $ idpList , array $ preferredEntityIds ): WayfSplitResult
3637 {
3738 return $ this ->splitter ->split ($ idpList , $ preferredEntityIds );
3839 }
@@ -57,8 +58,8 @@ public function testEmptyPreferredEntityIdsReturnsFullListAsRegular(): void
5758
5859 $ result = $ this ->split ($ idpList , []);
5960
60- $ this ->assertSame ([], $ result[ ' preferred ' ] );
61- $ this ->assertSame ($ idpList , $ result[ ' regular ' ] );
61+ $ this ->assertSame ([], $ result-> preferred );
62+ $ this ->assertSame ($ idpList , $ result-> regular );
6263 }
6364
6465 public function testPreferredIdpIsMovedOutOfRegularList (): void
@@ -68,10 +69,10 @@ public function testPreferredIdpIsMovedOutOfRegularList(): void
6869
6970 $ result = $ this ->split ([$ idp1 , $ idp2 ], ['https://idp1.example.org ' ]);
7071
71- $ this ->assertCount (1 , $ result[ ' preferred ' ] );
72- $ this ->assertSame ('https://idp1.example.org ' , $ result[ ' preferred ' ] [0 ]->entityId );
73- $ this ->assertCount (1 , $ result[ ' regular ' ] );
74- $ this ->assertSame ('https://idp2.example.org ' , $ result[ ' regular ' ] [0 ]->entityId );
72+ $ this ->assertCount (1 , $ result-> preferred );
73+ $ this ->assertSame ('https://idp1.example.org ' , $ result-> preferred [0 ]->entityId );
74+ $ this ->assertCount (1 , $ result-> regular );
75+ $ this ->assertSame ('https://idp2.example.org ' , $ result-> regular [0 ]->entityId );
7576 }
7677
7778 public function testConfiguredOrderIsPreservedInPreferredList (): void
@@ -85,11 +86,11 @@ public function testConfiguredOrderIsPreservedInPreferredList(): void
8586 ['https://idp3.example.org ' , 'https://idp1.example.org ' ]
8687 );
8788
88- $ this ->assertCount (2 , $ result[ ' preferred ' ] );
89- $ this ->assertSame ('https://idp3.example.org ' , $ result[ ' preferred ' ] [0 ]->entityId );
90- $ this ->assertSame ('https://idp1.example.org ' , $ result[ ' preferred ' ] [1 ]->entityId );
91- $ this ->assertCount (1 , $ result[ ' regular ' ] );
92- $ this ->assertSame ('https://idp2.example.org ' , $ result[ ' regular ' ] [0 ]->entityId );
89+ $ this ->assertCount (2 , $ result-> preferred );
90+ $ this ->assertSame ('https://idp3.example.org ' , $ result-> preferred [0 ]->entityId );
91+ $ this ->assertSame ('https://idp1.example.org ' , $ result-> preferred [1 ]->entityId );
92+ $ this ->assertCount (1 , $ result-> regular );
93+ $ this ->assertSame ('https://idp2.example.org ' , $ result-> regular [0 ]->entityId );
9394 }
9495
9596 public function testDisconnectedPreferredIdpIsExcludedFromBothLists (): void
@@ -102,10 +103,10 @@ public function testDisconnectedPreferredIdpIsExcludedFromBothLists(): void
102103 ['https://idp2.example.org ' ]
103104 );
104105
105- $ this ->assertSame ([], $ result[ ' preferred ' ] );
106+ $ this ->assertSame ([], $ result-> preferred );
106107 // idp1 is not preferred so it stays in regular; idp2 is preferred but disconnected > excluded from both
107- $ this ->assertCount (1 , $ result[ ' regular ' ] );
108- $ this ->assertSame ('https://idp1.example.org ' , $ result[ ' regular ' ] [0 ]->entityId );
108+ $ this ->assertCount (1 , $ result-> regular );
109+ $ this ->assertSame ('https://idp1.example.org ' , $ result-> regular [0 ]->entityId );
109110 }
110111
111112 public function testMultipleDiscoveryEntriesForSameEntityIdAreGroupedInOrder (): void
@@ -119,11 +120,11 @@ public function testMultipleDiscoveryEntriesForSameEntityIdAreGroupedInOrder():
119120 ['https://idp1.example.org ' ]
120121 );
121122
122- $ this ->assertCount (2 , $ result[ ' preferred ' ] );
123- $ this ->assertSame ('https://idp1.example.org ' , $ result[ ' preferred ' ] [0 ]->entityId );
124- $ this ->assertSame ('https://idp1.example.org ' , $ result[ ' preferred ' ] [1 ]->entityId );
125- $ this ->assertCount (1 , $ result[ ' regular ' ] );
126- $ this ->assertSame ('https://idp2.example.org ' , $ result[ ' regular ' ] [0 ]->entityId );
123+ $ this ->assertCount (2 , $ result-> preferred );
124+ $ this ->assertSame ('https://idp1.example.org ' , $ result-> preferred [0 ]->entityId );
125+ $ this ->assertSame ('https://idp1.example.org ' , $ result-> preferred [1 ]->entityId );
126+ $ this ->assertCount (1 , $ result-> regular );
127+ $ this ->assertSame ('https://idp2.example.org ' , $ result-> regular [0 ]->entityId );
127128 }
128129
129130 public function testPreferredEntityIdNotInIdpListIsIgnored (): void
@@ -132,8 +133,8 @@ public function testPreferredEntityIdNotInIdpListIsIgnored(): void
132133
133134 $ result = $ this ->split ([$ idp1 ], ['https://nonexistent.example.org ' ]);
134135
135- $ this ->assertSame ([], $ result[ ' preferred ' ] );
136- $ this ->assertCount (1 , $ result[ ' regular ' ] );
136+ $ this ->assertSame ([], $ result-> preferred );
137+ $ this ->assertCount (1 , $ result-> regular );
137138 }
138139
139140 public static function fiveScenarioProvider (): array
@@ -162,8 +163,8 @@ public function testFiveScenarioBannerAndPreferredVisibility(
162163
163164 $ split = $ this ->split ($ idpList , $ preferredEntityIds );
164165
165- $ showPreferred = ! empty ( $ split[ ' preferred ' ] );
166- $ isDefaultPreferred = in_array ($ defaultIdpEntityId, $ preferredEntityIds , true );
166+ $ showPreferred = $ split-> hasPreferred ( );
167+ $ isDefaultPreferred = $ split -> containsInPreferred ($ defaultIdpEntityId );
167168 $ showBanner = $ defaultIdpConnected && (!$ showPreferred || !$ isDefaultPreferred );
168169
169170 $ this ->assertSame ($ expectShowPreferred , $ showPreferred , 'showPreferredIdps mismatch ' );
0 commit comments