1313 * @internal
1414 */
1515abstract class ListContentNodeTestCase extends ECampApiTestCase {
16+ protected string $ endpointBase = '' ;
17+
1618 // content nodes visible for user 1, 2, 3
17- protected array $ contentNodesCamp1and2 = [];
19+ protected array $ contentNodesCamp1 = [];
20+ protected array $ contentNodesCamp2 = [];
1821
1922 // content nodes visislb for user 4
2023 protected array $ contentNodesCampUnrelated = [];
2124
2225 // content nodes visible for everyone
23- protected array $ contentNodesPublicCamps = [];
26+ protected array $ contentNodesCampPrototype = [];
27+ protected array $ contentNodesCampShared = [];
2428
2529 public function setUp (): void {
2630 parent ::setUp ();
2731 }
2832
2933 public function testListForAnonymousUser () {
34+ $ this ->endpoint = $ this ->endpointBase ;
3035 static ::createBasicClient ()->request ('GET ' , $ this ->endpoint );
3136 $ this ->assertResponseStatusCodeSame (401 );
3237 $ this ->assertJsonContains ([
@@ -36,38 +41,139 @@ public function testListForAnonymousUser() {
3641 }
3742
3843 public function testListForInvitedCollaborator () {
44+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campPrototype ' );
45+ $ response = $ this ->list (user: static ::$ fixtures ['user6invited ' ]);
46+ $ this ->assertResponseStatusCodeSame (200 );
47+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCampPrototype );
48+
49+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campShared ' );
3950 $ response = $ this ->list (user: static ::$ fixtures ['user6invited ' ]);
4051 $ this ->assertResponseStatusCodeSame (200 );
41- $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesPublicCamps );
52+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCampShared );
53+
54+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campUnrelated ' );
55+ $ response = $ this ->list (user: static ::$ fixtures ['user6invited ' ]);
56+ $ this ->assertResponseStatusCodeSame (400 );
57+ $ this ->assertJsonContains (['status ' => 400 ]);
4258 }
4359
4460 public function testListForInactiveCollaborator () {
61+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campPrototype ' );
4562 $ response = $ this ->list (user: static ::$ fixtures ['user5inactive ' ]);
4663 $ this ->assertResponseStatusCodeSame (200 );
47- $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesPublicCamps );
64+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCampPrototype );
65+
66+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campShared ' );
67+ $ response = $ this ->list (user: static ::$ fixtures ['user5inactive ' ]);
68+ $ this ->assertResponseStatusCodeSame (200 );
69+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCampShared );
70+
71+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campUnrelated ' );
72+ $ response = $ this ->list (user: static ::$ fixtures ['user5inactive ' ]);
73+ $ this ->assertResponseStatusCodeSame (400 );
74+ $ this ->assertJsonContains (['status ' => 400 ]);
4875 }
4976
5077 public function testListForUnrelatedUser () {
78+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campUnrelated ' );
79+ $ response = $ this ->list (user: static ::$ fixtures ['user4unrelated ' ]);
80+ $ this ->assertResponseStatusCodeSame (200 );
81+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCampUnrelated );
82+
83+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campPrototype ' );
84+ $ response = $ this ->list (user: static ::$ fixtures ['user4unrelated ' ]);
85+ $ this ->assertResponseStatusCodeSame (200 );
86+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCampPrototype );
87+
88+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campShared ' );
5189 $ response = $ this ->list (user: static ::$ fixtures ['user4unrelated ' ]);
5290 $ this ->assertResponseStatusCodeSame (200 );
53- $ this ->assertJsonContainsItems ($ response , array_merge ($ this ->contentNodesCampUnrelated , $ this ->contentNodesPublicCamps ));
91+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCampShared );
92+
93+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('camp1 ' );
94+ $ response = $ this ->list (user: static ::$ fixtures ['user4unrelated ' ]);
95+ $ this ->assertResponseStatusCodeSame (400 );
96+ $ this ->assertJsonContains (['status ' => 400 ]);
5497 }
5598
5699 public function testListForGuest () {
100+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('camp1 ' );
101+ $ response = $ this ->list (user: static ::$ fixtures ['user3guest ' ]);
102+ $ this ->assertResponseStatusCodeSame (200 );
103+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCamp1 );
104+
105+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('camp2 ' );
106+ $ response = $ this ->list (user: static ::$ fixtures ['user3guest ' ]);
107+ $ this ->assertResponseStatusCodeSame (200 );
108+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCamp2 );
109+
110+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campPrototype ' );
111+ $ response = $ this ->list (user: static ::$ fixtures ['user3guest ' ]);
112+ $ this ->assertResponseStatusCodeSame (200 );
113+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCampPrototype );
114+
115+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campShared ' );
57116 $ response = $ this ->list (user: static ::$ fixtures ['user3guest ' ]);
58117 $ this ->assertResponseStatusCodeSame (200 );
59- $ this ->assertJsonContainsItems ($ response , array_merge ($ this ->contentNodesCamp1and2 , $ this ->contentNodesPublicCamps ));
118+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCampShared );
119+
120+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campUnrelated ' );
121+ $ response = $ this ->list (user: static ::$ fixtures ['user3guest ' ]);
122+ $ this ->assertResponseStatusCodeSame (400 );
123+ $ this ->assertJsonContains (['status ' => 400 ]);
60124 }
61125
62126 public function testListForMember () {
127+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('camp1 ' );
128+ $ response = $ this ->list (user: static ::$ fixtures ['user2member ' ]);
129+ $ this ->assertResponseStatusCodeSame (200 );
130+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCamp1 );
131+
132+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('camp2 ' );
133+ $ response = $ this ->list (user: static ::$ fixtures ['user2member ' ]);
134+ $ this ->assertResponseStatusCodeSame (200 );
135+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCamp2 );
136+
137+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campPrototype ' );
138+ $ response = $ this ->list (user: static ::$ fixtures ['user2member ' ]);
139+ $ this ->assertResponseStatusCodeSame (200 );
140+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCampPrototype );
141+
142+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campShared ' );
63143 $ response = $ this ->list (user: static ::$ fixtures ['user2member ' ]);
64144 $ this ->assertResponseStatusCodeSame (200 );
65- $ this ->assertJsonContainsItems ($ response , array_merge ($ this ->contentNodesCamp1and2 , $ this ->contentNodesPublicCamps ));
145+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCampShared );
146+
147+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campUnrelated ' );
148+ $ response = $ this ->list (user: static ::$ fixtures ['user2member ' ]);
149+ $ this ->assertResponseStatusCodeSame (400 );
150+ $ this ->assertJsonContains (['status ' => 400 ]);
66151 }
67152
68153 public function testListForManager () {
154+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('camp1 ' );
69155 $ response = $ this ->list (user: static ::$ fixtures ['user1manager ' ]);
70156 $ this ->assertResponseStatusCodeSame (200 );
71- $ this ->assertJsonContainsItems ($ response , array_merge ($ this ->contentNodesCamp1and2 , $ this ->contentNodesPublicCamps ));
157+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCamp1 );
158+
159+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('camp2 ' );
160+ $ response = $ this ->list (user: static ::$ fixtures ['user1manager ' ]);
161+ $ this ->assertResponseStatusCodeSame (200 );
162+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCamp2 );
163+
164+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campPrototype ' );
165+ $ response = $ this ->list (user: static ::$ fixtures ['user1manager ' ]);
166+ $ this ->assertResponseStatusCodeSame (200 );
167+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCampPrototype );
168+
169+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campShared ' );
170+ $ response = $ this ->list (user: static ::$ fixtures ['user1manager ' ]);
171+ $ this ->assertResponseStatusCodeSame (200 );
172+ $ this ->assertJsonContainsItems ($ response , $ this ->contentNodesCampShared );
173+
174+ $ this ->endpoint = $ this ->endpointBase .'?camp= ' .$ this ->getIriFor ('campUnrelated ' );
175+ $ response = $ this ->list (user: static ::$ fixtures ['user1manager ' ]);
176+ $ this ->assertResponseStatusCodeSame (400 );
177+ $ this ->assertJsonContains (['status ' => 400 ]);
72178 }
73179}
0 commit comments