Skip to content

Commit 57bb82b

Browse files
committed
fix test
1 parent 903a0d2 commit 57bb82b

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

Diff for: api/src/Entity/ContentNode.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function setParent(?ContentNode $parent) {
194194
}
195195

196196
public function getCamp(): ?Camp {
197-
if ($this->getRoot()->campRootContentNodes->count() > 0) {
197+
if ($this->getRoot()->campRootContentNodes != null && $this->getRoot()->campRootContentNodes->count() > 0) {
198198
return $this->getRoot()->campRootContentNodes[0]->camp;
199199
}
200200

Diff for: api/tests/Api/MaterialItems/CreateMaterialItemTest.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,18 @@ public function testCreateMaterialItemWithPeriodFromQueryParameter() {
159159
public function testCreateMaterialItemValidatesMissingPeriodAndMaterialNode() {
160160
static::createClientWithCredentials()->request('POST', '/material_items', ['json' => $this->getExampleWritePayload([], ['period', 'materialNode'])]);
161161

162-
$this->assertResponseStatusCodeSame(403);
162+
$this->assertResponseStatusCodeSame(422);
163163
$this->assertJsonContains([
164-
'title' => 'An error occurred',
165-
'detail' => 'Access Denied.',
164+
'violations' => [
165+
[
166+
'propertyPath' => 'period',
167+
'message' => 'Either this value or materialNode should not be null.',
168+
],
169+
[
170+
'propertyPath' => 'materialNode',
171+
'message' => 'Either this value or period should not be null.',
172+
],
173+
],
166174
]);
167175
}
168176

Diff for: api/tests/Api/MaterialItems/UpdateMaterialItemTest.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,12 @@ public function testPatchMaterialItemValidatesMissingPeriodAndMaterialNode() {
201201
$this->assertJsonContains([
202202
'violations' => [
203203
[
204-
'propertyPath' => 'materialList',
205-
'message' => 'Must belong to the same camp.',
204+
'propertyPath' => 'period',
205+
'message' => 'Either this value or materialNode should not be null.',
206+
],
207+
[
208+
'propertyPath' => 'materialNode',
209+
'message' => 'Either this value or period should not be null.',
206210
],
207211
],
208212
]);

0 commit comments

Comments
 (0)