Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"ext-libxml": "*",
"ext-simplexml": "*",
"ext-xmlwriter": "*",
"ibexa/core": "~4.6.0@dev",
Comment thread
mikadamczyk marked this conversation as resolved.
"ibexa/core": "dev-ct-group-is-system as 4.6.x-dev",
Comment thread
mikadamczyk marked this conversation as resolved.
Outdated
"symfony/http-kernel": "^5.3",
"symfony/dependency-injection": "^5.3",
"symfony/routing": "^5.3",
Expand Down
4 changes: 3 additions & 1 deletion src/lib/Server/Controller/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ public function loadContentTypeGroupList(Request $request)
);
}

$includeSystem = $request->query->getBoolean('includeSystem', false);

return new Values\ContentTypeGroupList(
$this->contentTypeService->loadContentTypeGroups(Language::ALL)
$this->contentTypeService->loadContentTypeGroups(Language::ALL, $includeSystem)
);
}

Expand Down
7 changes: 6 additions & 1 deletion src/lib/Server/Input/Parser/Criterion/LogicalNot.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LogicalNot extends CriterionParser
*/
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
{
if (!array_key_exists('NOT', $data) && !is_array($data['NOT'])) {
if (!array_key_exists('NOT', $data) || !is_array($data['NOT'])) {
throw new Exceptions\Parser('Invalid <NOT> format');
}

Expand All @@ -37,6 +37,11 @@ public function parse(array $data, ParsingDispatcher $parsingDispatcher)
}
$criterionName = key($data['NOT']);
$criterionData = current($data['NOT']);

if (!is_string($criterionName)) {
throw new Exceptions\Parser('Invalid <NOT> format');
}

$criteria = $this->dispatchCriterion($criterionName, $criterionData, $parsingDispatcher);

return new LogicalNotCriterion($criteria);
Expand Down
56 changes: 56 additions & 0 deletions tests/lib/Server/Controller/ContentTypeControllerTest.php
Comment thread
mikadamczyk marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace Ibexa\Tests\Rest\Server\Controller;

use Ibexa\Contracts\Core\Repository\ContentTypeService;
use Ibexa\Contracts\Core\Repository\Values\Content\Language;
use Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup;
use Ibexa\Rest\Server\Controller\ContentType;
use Ibexa\Rest\Server\Values\ContentTypeGroupList;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;

final class ContentTypeControllerTest extends TestCase
{
public function testLoadContentTypeGroupListDefaultsToNonSystem(): void
{
$contentTypeService = $this->createMock(ContentTypeService::class);
$contentTypeGroups = [$this->createMock(ContentTypeGroup::class)];

$contentTypeService
->expects(self::once())
->method('loadContentTypeGroups')
->with(Language::ALL, false)
->willReturn($contentTypeGroups);

$controller = new ContentType($contentTypeService);

$result = $controller->loadContentTypeGroupList(new Request());

self::assertInstanceOf(ContentTypeGroupList::class, $result);
self::assertSame($contentTypeGroups, $result->contentTypeGroups);
}

public function testLoadContentTypeGroupListIncludesSystemWhenRequested(): void
{
$contentTypeService = $this->createMock(ContentTypeService::class);
$contentTypeGroups = [$this->createMock(ContentTypeGroup::class)];

$contentTypeService
->expects(self::once())
->method('loadContentTypeGroups')
->with(Language::ALL, true)
->willReturn($contentTypeGroups);

$controller = new ContentType($contentTypeService);

$result = $controller->loadContentTypeGroupList(new Request(['includeSystem' => 'true']));

self::assertInstanceOf(ContentTypeGroupList::class, $result);
self::assertSame($contentTypeGroups, $result->contentTypeGroups);
}
}
Loading