Skip to content

Commit 357697e

Browse files
committed
Add isSystem property to ContentTypeGroupCreateStruct
1 parent 1aee655 commit 357697e

3 files changed

Lines changed: 63 additions & 2 deletions

File tree

src/lib/Server/Input/Parser/ContentTypeGroupInput.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function parse(array $data, ParsingDispatcher $parsingDispatcher)
6868
$contentTypeGroupCreateStruct->creationDate = new DateTime($data['modificationDate']);
6969
}
7070

71+
if (array_key_exists('isSystem', $data)) {
72+
$contentTypeGroupCreateStruct->isSystem = $this->parserTools->parseBooleanValue($data['isSystem']);
73+
}
74+
7175
// @todo mainLanguageCode, names, descriptions?
7276
7377
if (array_key_exists('User', $data) && is_array($data['User'])) {

tests/bundle/Functional/ContentTypeTest.php

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ public function testLoadContentTypeGroupList()
165165
*/
166166
public function testLoadContentTypeGroupListExcludesSystemByDefault(): void
167167
{
168+
$systemIdentifier = $this->createSystemContentTypeGroup();
169+
168170
$response = $this->sendHttpRequest(
169171
$this->createHttpRequest(
170172
'GET',
@@ -177,14 +179,16 @@ public function testLoadContentTypeGroupListExcludesSystemByDefault(): void
177179

178180
$identifiers = $this->getContentTypeGroupIdentifiers($response);
179181

180-
self::assertNotContains('system', $identifiers);
182+
self::assertNotContains($systemIdentifier, $identifiers);
181183
}
182184

183185
/**
184186
* Covers GET /content/typegroups?includeSystem=true.
185187
*/
186188
public function testLoadContentTypeGroupListIncludesSystemGroups(): void
187189
{
190+
$systemIdentifier = $this->createSystemContentTypeGroup();
191+
188192
$response = $this->sendHttpRequest(
189193
$this->createHttpRequest(
190194
'GET',
@@ -197,7 +201,7 @@ public function testLoadContentTypeGroupListIncludesSystemGroups(): void
197201

198202
$identifiers = $this->getContentTypeGroupIdentifiers($response);
199203

200-
self::assertContains('system', $identifiers);
204+
self::assertContains($systemIdentifier, $identifiers);
201205
}
202206

203207
/**
@@ -213,6 +217,25 @@ public function testLoadContentTypeGroupListWithIdentifier()
213217
self::assertHttpResponseCodeEquals($response, 307);
214218
}
215219

220+
public function testCreateSystemContentTypeGroup(): void
221+
{
222+
$identifier = $this->createSystemContentTypeGroup();
223+
224+
$response = $this->sendHttpRequest(
225+
$this->createHttpRequest(
226+
'GET',
227+
'/api/ibexa/v2/content/typegroups?includeSystem=true',
228+
'',
229+
'ContentTypeGroupList+json'
230+
)
231+
);
232+
self::assertHttpResponseCodeEquals($response, 200);
233+
234+
$identifiers = $this->getContentTypeGroupIdentifiers($response);
235+
236+
self::assertContains($identifier, $identifiers);
237+
}
238+
216239
/**
217240
* @depends testUpdateContentTypeGroup
218241
* Covers GET /content/typegroups/<contentTypeGroupId>
@@ -734,6 +757,34 @@ static function (array $group): string {
734757
$groupList
735758
);
736759
}
760+
761+
private function createSystemContentTypeGroup(): string
762+
{
763+
$identifier = $this->addTestSuffix('system_group_' . uniqid());
764+
$body = <<< XML
765+
<?xml version="1.0" encoding="UTF-8"?>
766+
<ContentTypeGroupInput>
767+
<identifier>{$identifier}</identifier>
768+
<isSystem>true</isSystem>
769+
</ContentTypeGroupInput>
770+
XML;
771+
772+
$request = $this->createHttpRequest(
773+
'POST',
774+
'/api/ibexa/v2/content/typegroups',
775+
'ContentTypeGroupInput+xml',
776+
'ContentTypeGroup+json',
777+
$body
778+
);
779+
780+
$response = $this->sendHttpRequest($request);
781+
self::assertHttpResponseCodeEquals($response, 201);
782+
self::assertHttpResponseHasHeader($response, 'Location');
783+
784+
$this->addCreatedElement($response->getHeader('Location')[0]);
785+
786+
return $identifier;
787+
}
737788
}
738789

739790
class_alias(ContentTypeTest::class, 'EzSystems\EzPlatformRestBundle\Tests\Functional\ContentTypeTest');

tests/lib/Server/Input/Parser/ContentTypeGroupInputTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function testParse()
2424
'_href' => '/user/users/14',
2525
],
2626
'modificationDate' => '2012-12-31T12:00:00',
27+
'isSystem' => true,
2728
];
2829

2930
$contentTypeGroupInput = $this->getParser();
@@ -52,6 +53,11 @@ public function testParse()
5253
$result->creationDate,
5354
'ContentTypeGroupCreateStruct creationDate property not created correctly.'
5455
);
56+
57+
$this->assertTrue(
58+
$result->isSystem,
59+
'ContentTypeGroupCreateStruct isSystem property not created correctly.'
60+
);
5561
}
5662

5763
/**

0 commit comments

Comments
 (0)