File tree 4 files changed +25
-6
lines changed
tests/Integration/Resource
4 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ More examples can be found in the [examples](examples) directory.
60
60
| Endpoint | Status Code | Response | API |
61
61
| ----------| -------------| ----------| -----|
62
62
| ` POST /auth/admin/realms ` | ` 201 ` | [ Realm] ( src/Representation/Realm.php ) | [ Realms::import()] ( src/Resource/Realms.php ) |
63
- | ` GET /auth/admin/realms ` | ` 200 ` | array< [ Realm ] ( src/Representation/Realm .php ) > | [ Realms::all()] ( src/Resource/Realms.php ) |
63
+ | ` GET /auth/admin/realms ` | ` 200 ` | [ RealmCollection ] ( src/Collection/RealmCollection .php ) > | [ Realms::all()] ( src/Resource/Realms.php ) |
64
64
| ` PUT /auth/admin/realms/{realm} ` | ` 204 ` | [ Realm] ( src/Representation/Realm.php ) | [ Realms::update()] ( src/Resource/Realms.php ) |
65
65
| ` DELETE /auth/admin/realms/{realm} ` | ` 204 ` | ` n/a ` | [ Realms::delete()] ( src/Resource/Realms.php ) |
66
66
| ` GET /auth/admin/realms/{realm}/admin-events ` | ` 200 ` | ` array ` | [ Realms::adminEvents()] ( src/Resource/Realms.php ) |
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Fschmtt \Keycloak \Collection ;
6
+
7
+ use Fschmtt \Keycloak \Representation \Realm ;
8
+
9
+ /**
10
+ * @method Realm[] getIterator()
11
+ */
12
+ class RealmCollection extends Collection
13
+ {
14
+ public static function getRepresentationClass (): string
15
+ {
16
+ return Realm::class;
17
+ }
18
+ }
Original file line number Diff line number Diff line change 6
6
7
7
use Fschmtt \Keycloak \Collection \ClientCollection ;
8
8
use Fschmtt \Keycloak \Collection \GroupCollection ;
9
+ use Fschmtt \Keycloak \Collection \RealmCollection ;
9
10
use Fschmtt \Keycloak \Collection \UserCollection ;
10
11
use Fschmtt \Keycloak \Json \JsonDecoder ;
11
12
use Fschmtt \Keycloak \Json \JsonEncoder ;
@@ -17,7 +18,7 @@ class Realms extends Resource
17
18
{
18
19
private const BASE_PATH = '/auth/admin/realms ' ;
19
20
20
- public function all (): array
21
+ public function all (): RealmCollection
21
22
{
22
23
/** @var Realm[] $realms */
23
24
$ realms = [];
@@ -33,7 +34,7 @@ public function all(): array
33
34
$ realms [] = Realm::from ($ realm );
34
35
}
35
36
36
- return $ realms ;
37
+ return new RealmCollection ( $ realms) ;
37
38
}
38
39
39
40
public function get (string $ realm ): Realm
Original file line number Diff line number Diff line change 4
4
5
5
namespace Fschmtt \Keycloak \Test \Integration \Resource ;
6
6
7
+ use Fschmtt \Keycloak \Collection \RealmCollection ;
7
8
use Fschmtt \Keycloak \Representation \Realm ;
8
9
use Fschmtt \Keycloak \Test \Integration \IntegrationTestBehaviour ;
9
10
use PHPUnit \Framework \TestCase ;
@@ -16,9 +17,8 @@ public function testCanGetAllRealms(): void
16
17
{
17
18
$ realms = $ this ->getKeycloak ()->realms ()->all ();
18
19
19
- foreach ($ realms as $ realm ) {
20
- static ::assertInstanceOf (Realm::class, $ realm );
21
- }
20
+ static ::assertInstanceOf (RealmCollection::class, $ realms );
21
+ static ::assertCount (1 , $ realms );
22
22
}
23
23
24
24
public function testCanGetRealm (): void
You can’t perform that action at this time.
0 commit comments