-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] Added integration coverage for REST load-subtree endpoint
- Loading branch information
Showing
7 changed files
with
289 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Integration\AdminUi\REST; | ||
|
||
use Ibexa\Contracts\Test\Rest\BaseRestWebTestCase; | ||
|
||
/** | ||
* Requires \Ibexa\Tests\Integration\AdminUi\AdminUiIbexaTestKernel kernel. | ||
* | ||
* @see \Ibexa\Tests\Integration\AdminUi\AdminUiIbexaTestKernel | ||
*/ | ||
abstract class BaseAdminUiRestWebTestCase extends BaseRestWebTestCase | ||
{ | ||
protected function getSchemaFileBasePath(string $resourceType, string $format): string | ||
{ | ||
return dirname(__DIR__) . '/Resources/REST/Schemas/' . $resourceType; | ||
} | ||
|
||
protected static function getSnapshotDirectory(): ?string | ||
{ | ||
return dirname(__DIR__) . '/Resources/REST/Snapshots'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Integration\AdminUi\REST; | ||
|
||
use Ibexa\Contracts\Core\Repository\BookmarkService; | ||
use Ibexa\Contracts\Test\Rest\Input\PayloadLoader; | ||
use Ibexa\Contracts\Test\Rest\Request\Value\EndpointRequestDefinition; | ||
|
||
/** | ||
* Coverage for /location/load-subtree REST endpoint. | ||
*/ | ||
final class PostPostLoadSubtreeTest extends BaseAdminUiRestWebTestCase | ||
{ | ||
private const INPUT_MEDIA_TYPE = 'ContentTreeLoadSubtreeRequest'; | ||
|
||
/** | ||
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$ibexaTestCore = $this->getIbexaTestCore(); | ||
$ibexaTestCore->setAdministratorUser(); | ||
$bookmarkService = $ibexaTestCore->getServiceByClassName(BookmarkService::class); | ||
$locationService = $ibexaTestCore->getLocationService(); | ||
$location = $locationService->loadLocation(2); | ||
$bookmarkService->createBookmark($location); | ||
} | ||
|
||
protected static function getEndpointsToTest(): iterable | ||
{ | ||
$payloadLoader = new PayloadLoader(dirname(__DIR__) . '/Resources/REST/InputPayloads'); | ||
|
||
yield new EndpointRequestDefinition( | ||
'POST', | ||
'/api/ibexa/v2/location/tree/load-subtree', | ||
'ContentTreeRoot', | ||
'application/vnd.ibexa.api.ContentTreeRoot+json', | ||
['HTTP_X-SiteAccess' => 'admin'], | ||
$payloadLoader->loadPayload(self::INPUT_MEDIA_TYPE, 'json'), | ||
null, | ||
'ContentTreeRoot' | ||
); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/integration/Resources/REST/InputPayloads/ContentTreeLoadSubtreeRequest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"LoadSubtreeRequest": { | ||
"_media-type": "application/vnd.ibexa.api.ContentTreeLoadSubtreeRequest", | ||
"nodes": [ | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.ContentTreeLoadSubtreeRequestNode", | ||
"locationId": 2, | ||
"limit": 30, | ||
"offset": 0, | ||
"children": [ | ||
{ | ||
"_media-type": "application/vnd.ibexa.api.ContentTreeLoadSubtreeRequestNode", | ||
"locationId": 1, | ||
"limit": 200, | ||
"offset": 0, | ||
"children": [] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
139 changes: 139 additions & 0 deletions
139
tests/integration/Resources/REST/Schemas/ContentTreeRoot.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"type": "object", | ||
"properties": { | ||
"ContentTreeRoot": { | ||
"type": "object", | ||
"properties": { | ||
"_media-type": { | ||
"type": "string" | ||
}, | ||
"ContentTreeNodeList": { | ||
"type": "array", | ||
"items": [ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"_media-type": { | ||
"type": "string" | ||
}, | ||
"locationId": { | ||
"type": "integer" | ||
}, | ||
"contentId": { | ||
"type": "integer" | ||
}, | ||
"name": { | ||
"type": "string" | ||
}, | ||
"contentTypeIdentifier": { | ||
"type": "string" | ||
}, | ||
"isContainer": { | ||
"type": "boolean" | ||
}, | ||
"isInvisible": { | ||
"type": "boolean" | ||
}, | ||
"displayLimit": { | ||
"type": "integer" | ||
}, | ||
"totalChildrenCount": { | ||
"type": "integer" | ||
}, | ||
"reverseRelationsCount": { | ||
"type": "integer" | ||
}, | ||
"isBookmarked": { | ||
"type": "boolean" | ||
}, | ||
"children": { | ||
"type": "array", | ||
"items": [ | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"_media-type": { | ||
"type": "string" | ||
}, | ||
"locationId": { | ||
"type": "integer" | ||
}, | ||
"contentId": { | ||
"type": "integer" | ||
}, | ||
"name": { | ||
"type": "string" | ||
}, | ||
"contentTypeIdentifier": { | ||
"type": "string" | ||
}, | ||
"isContainer": { | ||
"type": "boolean" | ||
}, | ||
"isInvisible": { | ||
"type": "boolean" | ||
}, | ||
"displayLimit": { | ||
"type": "integer" | ||
}, | ||
"totalChildrenCount": { | ||
"type": "integer" | ||
}, | ||
"reverseRelationsCount": { | ||
"type": "integer" | ||
}, | ||
"isBookmarked": { | ||
"type": "boolean" | ||
}, | ||
"children": { | ||
"type": "array", | ||
"items": {} | ||
} | ||
}, | ||
"required": [ | ||
"_media-type", | ||
"locationId", | ||
"contentId", | ||
"name", | ||
"contentTypeIdentifier", | ||
"isContainer", | ||
"isInvisible", | ||
"displayLimit", | ||
"totalChildrenCount", | ||
"reverseRelationsCount", | ||
"isBookmarked", | ||
"children" | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"_media-type", | ||
"locationId", | ||
"contentId", | ||
"name", | ||
"contentTypeIdentifier", | ||
"isContainer", | ||
"isInvisible", | ||
"displayLimit", | ||
"totalChildrenCount", | ||
"reverseRelationsCount", | ||
"isBookmarked", | ||
"children" | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"_media-type", | ||
"ContentTreeNodeList" | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"ContentTreeRoot" | ||
] | ||
} |
36 changes: 36 additions & 0 deletions
36
tests/integration/Resources/REST/Snapshots/ContentTreeRoot.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"ContentTreeRoot": { | ||
"_media-type": "application\/vnd.ibexa.api.ContentTreeRoot+json", | ||
"ContentTreeNodeList": [ | ||
{ | ||
"_media-type": "application\/vnd.ibexa.api.ContentTreeNode+json", | ||
"locationId": 2, | ||
"contentId": 57, | ||
"name": "Home", | ||
"contentTypeIdentifier": "landing_page", | ||
"isContainer": true, | ||
"isInvisible": false, | ||
"displayLimit": 30, | ||
"totalChildrenCount": 1, | ||
"reverseRelationsCount": 0, | ||
"isBookmarked": true, | ||
"children": [ | ||
{ | ||
"_media-type": "application\/vnd.ibexa.api.ContentTreeNode+json", | ||
"locationId": 60, | ||
"contentId": 58, | ||
"name": "Contact Us", | ||
"contentTypeIdentifier": "feedback_form", | ||
"isContainer": true, | ||
"isInvisible": false, | ||
"displayLimit": 30, | ||
"totalChildrenCount": 0, | ||
"reverseRelationsCount": 0, | ||
"isBookmarked": false, | ||
"children": [] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters