Skip to content

Commit 8b4453d

Browse files
committed
add tests for filtered content-node-endpoints
1 parent 6e5a71d commit 8b4453d

File tree

8 files changed

+208
-70
lines changed

8 files changed

+208
-70
lines changed

api/tests/Api/ContentNodes/ChecklistNode/ListChecklistNodeTest.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,23 @@ class ListChecklistNodeTest extends ListContentNodeTestCase {
1111
public function setUp(): void {
1212
parent::setUp();
1313

14-
$this->endpoint = '/content_node/checklist_nodes?camp=/camps/'.static::$fixtures['campPrototype']->getId();
14+
$this->endpointBase = '/content_node/checklist_nodes';
1515

16-
$this->contentNodesCamp1and2 = [
17-
// $this->getIriFor('checklistNode1'),
18-
// $this->getIriFor('checklistNode3'),
16+
$this->contentNodesCamp1 = [
17+
$this->getIriFor('checklistNode1'),
18+
$this->getIriFor('checklistNode3'),
19+
];
20+
$this->contentNodesCamp2 = [
21+
// none
1922
];
20-
2123
$this->contentNodesCampUnrelated = [
22-
// $this->getIriFor('checklistNodeCampUnrelated'),
24+
$this->getIriFor('checklistNodeCampUnrelated'),
2325
];
24-
25-
$this->contentNodesPublicCamps = [
26+
$this->contentNodesCampPrototype = [
2627
$this->getIriFor('checklistNodeCampPrototype'),
27-
// $this->getIriFor('checklistNodeCampShared'),
28+
];
29+
$this->contentNodesCampShared = [
30+
$this->getIriFor('checklistNodeCampShared'),
2831
];
2932
}
3033
}

api/tests/Api/ContentNodes/ColumnLayout/ListColumnLayoutTest.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,28 @@ class ListColumnLayoutTest extends ListContentNodeTestCase {
1111
public function setUp(): void {
1212
parent::setUp();
1313

14-
$this->endpoint = '/content_node/column_layouts?camp=/camps/'.static::$fixtures['campPrototype']->getId();
14+
$this->endpointBase = '/content_node/column_layouts';
1515

16-
$this->contentNodesCamp1and2 = [
17-
// $this->getIriFor('columnLayout1'),
18-
// $this->getIriFor('columnLayout2'),
19-
// $this->getIriFor('columnLayoutChild1'),
20-
// $this->getIriFor('columnLayout2Child1'),
21-
// $this->getIriFor('columnLayout3'),
22-
// $this->getIriFor('columnLayout4'),
23-
// $this->getIriFor('columnLayout5'),
24-
// $this->getIriFor('columnLayout1camp2'),
25-
// $this->getIriFor('columnLayout2camp2'),
16+
$this->contentNodesCamp1 = [
17+
$this->getIriFor('columnLayout1'),
18+
$this->getIriFor('columnLayoutChild1'),
19+
$this->getIriFor('columnLayout3'),
20+
];
21+
$this->contentNodesCamp2 = [
22+
$this->getIriFor('columnLayout1camp2'),
2623
];
2724

2825
$this->contentNodesCampUnrelated = [
29-
// $this->getIriFor('columnLayout1campUnrelated'),
30-
// $this->getIriFor('columnLayout2campUnrelated'),
26+
$this->getIriFor('columnLayout1campUnrelated'),
3127
];
3228

33-
$this->contentNodesPublicCamps = [
29+
$this->contentNodesCampPrototype = [
3430
$this->getIriFor('columnLayout1campPrototype'),
35-
// $this->getIriFor('columnLayout2campPrototype'),
3631
$this->getIriFor('columnLayout3campPrototype'),
37-
// $this->getIriFor('columnLayout1campShared'),
38-
// $this->getIriFor('columnLayout2campShared'),
39-
// $this->getIriFor('columnLayout3campShared'),
32+
];
33+
$this->contentNodesCampShared = [
34+
$this->getIriFor('columnLayout1campShared'),
35+
$this->getIriFor('columnLayout3campShared'),
4036
];
4137
}
4238
}

api/tests/Api/ContentNodes/ListContentNodeTestCase.php

Lines changed: 114 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,25 @@
1313
* @internal
1414
*/
1515
abstract 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
}

api/tests/Api/ContentNodes/MaterialNode/ListMaterialNodeTest.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,26 @@ class ListMaterialNodeTest extends ListContentNodeTestCase {
1111
public function setUp(): void {
1212
parent::setUp();
1313

14-
$this->endpoint = '/content_node/material_nodes?camp=/camps/'.static::$fixtures['campPrototype']->getId();
14+
$this->endpointBase = '/content_node/material_nodes';
1515

16-
$this->contentNodesCamp1and2 = [
17-
// $this->getIriFor('materialNode1'),
18-
// $this->getIriFor('materialNode2'),
16+
$this->contentNodesCamp1 = [
17+
$this->getIriFor('materialNode1'),
18+
];
19+
20+
$this->contentNodesCamp2 = [
21+
$this->getIriFor('materialNode2'),
1922
];
2023

2124
$this->contentNodesCampUnrelated = [
22-
// $this->getIriFor('materialNodeCampUnrelated'),
25+
$this->getIriFor('materialNodeCampUnrelated'),
2326
];
2427

25-
$this->contentNodesPublicCamps = [
28+
$this->contentNodesCampPrototype = [
2629
$this->getIriFor('materialNodeCampPrototype'),
27-
// $this->getIriFor('materialNodeCampShared'),
30+
];
31+
32+
$this->contentNodesCampShared = [
33+
$this->getIriFor('materialNodeCampShared'),
2834
];
2935
}
3036
}

api/tests/Api/ContentNodes/MultiSelect/ListMultiSelectTest.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,26 @@ class ListMultiSelectTest extends ListContentNodeTestCase {
1111
public function setUp(): void {
1212
parent::setUp();
1313

14-
$this->endpoint = '/content_node/multi_selects?camp=/camps/'.static::$fixtures['campPrototype']->getId();
14+
$this->endpointBase = '/content_node/multi_selects';
1515

16-
$this->contentNodesCamp1and2 = [
17-
// $this->getIriFor('multiSelect1'),
18-
// $this->getIriFor('multiSelect2'),
16+
$this->contentNodesCamp1 = [
17+
$this->getIriFor('multiSelect1'),
18+
$this->getIriFor('multiSelect2'),
19+
];
20+
21+
$this->contentNodesCamp2 = [
1922
];
2023

2124
$this->contentNodesCampUnrelated = [
22-
// $this->getIriFor('multiSelectCampUnrelated'),
25+
$this->getIriFor('multiSelectCampUnrelated'),
2326
];
2427

25-
$this->contentNodesPublicCamps = [
28+
$this->contentNodesCampPrototype = [
2629
$this->getIriFor('multiSelectCampPrototype'),
27-
// $this->getIriFor('multiSelectCampShared'),
30+
];
31+
32+
$this->contentNodesCampShared = [
33+
$this->getIriFor('multiSelectCampShared'),
2834
];
2935
}
3036
}

api/tests/Api/ContentNodes/ResponsiveLayout/ListResponsiveLayoutTest.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,26 @@ class ListResponsiveLayoutTest extends ListContentNodeTestCase {
1111
public function setUp(): void {
1212
parent::setUp();
1313

14-
$this->endpoint = '/content_node/responsive_layouts?camp=/camps/'.static::$fixtures['campPrototype']->getId();
14+
$this->endpointBase = '/content_node/responsive_layouts';
1515

16-
$this->contentNodesCamp1and2 = [
17-
// $this->getIriFor('responsiveLayout1'),
16+
$this->contentNodesCamp1 = [
17+
$this->getIriFor('responsiveLayout1'),
18+
];
19+
20+
$this->contentNodesCamp2 = [
21+
// none
1822
];
1923

2024
$this->contentNodesCampUnrelated = [
21-
// $this->getIriFor('responsiveLayoutCampUnrelated'),
25+
$this->getIriFor('responsiveLayoutCampUnrelated'),
2226
];
2327

24-
$this->contentNodesPublicCamps = [
28+
$this->contentNodesCampPrototype = [
2529
$this->getIriFor('responsiveLayoutCampPrototype'),
26-
// $this->getIriFor('responsiveLayoutCampShared'),
30+
];
31+
32+
$this->contentNodesCampShared = [
33+
$this->getIriFor('responsiveLayoutCampShared'),
2734
];
2835
}
2936
}

api/tests/Api/ContentNodes/SingleText/ListSingleTextTest.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,28 @@ class ListSingleTextTest extends ListContentNodeTestCase {
1111
public function setUp(): void {
1212
parent::setUp();
1313

14-
$this->endpoint = '/content_node/single_texts?camp=/camps/'.static::$fixtures['campPrototype']->getId();
14+
$this->endpointBase = '/content_node/single_texts';
1515

16-
$this->contentNodesCamp1and2 = [
17-
// $this->getIriFor('singleText1'),
18-
// $this->getIriFor('singleText2'),
19-
// $this->getIriFor('safetyConsiderations1'),
16+
$this->contentNodesCamp1 = [
17+
$this->getIriFor('singleText1'),
18+
$this->getIriFor('singleText2'),
19+
$this->getIriFor('safetyConsiderations1'),
20+
];
21+
22+
$this->contentNodesCamp2 = [
23+
// none
2024
];
2125

2226
$this->contentNodesCampUnrelated = [
23-
// $this->getIriFor('singleTextCampUnrelated'),
27+
$this->getIriFor('singleTextCampUnrelated'),
2428
];
2529

26-
$this->contentNodesPublicCamps = [
30+
$this->contentNodesCampPrototype = [
2731
$this->getIriFor('singleTextCampPrototype'),
28-
// $this->getIriFor('singleTextCampShared'),
32+
];
33+
34+
$this->contentNodesCampShared = [
35+
$this->getIriFor('singleTextCampShared'),
2936
];
3037
}
3138
}

0 commit comments

Comments
 (0)