-
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.
Browse files
Browse the repository at this point in the history
…#1139) * Fixed isBookmarked property in load-subtree response * [PHPStan] Aligned baseline after the changes * [Composer] Installed ibexa/test-rest * [Composer] Auto-loaded integration tests namespace * [Composer] Added missing symfony/webpack-encore-bundle requirement * [Tests] Configured integration tests framework * [PHPStan] Aligned baseline with the changes * [Tests] Added integration coverage for REST load-subtree endpoint
- Loading branch information
Showing
15 changed files
with
516 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ package-lock.json | |
.DS_Store | ||
.phpunit.result.cache | ||
composer.lock | ||
/var |
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
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,18 @@ | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd" | ||
bootstrap="tests/integration/bootstrap.php" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
failOnWarning="true" | ||
verbose="true"> | ||
<php> | ||
<env name="KERNEL_CLASS" value="Ibexa\Tests\Integration\AdminUi\AdminUiIbexaTestKernel" /> | ||
<env name="SEARCH_ENGINE" value="legacy" /> | ||
<env name="DATABASE_URL" value="sqlite://i@i/var/test.db" /> | ||
</php> | ||
<testsuites> | ||
<testsuite name="integration"> | ||
<directory>tests/integration</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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,106 @@ | ||
<?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; | ||
|
||
use Hautelook\TemplatedUriBundle\HautelookTemplatedUriBundle; | ||
use Ibexa\Bundle\AdminUi\IbexaAdminUiBundle; | ||
use Ibexa\Bundle\ContentForms\IbexaContentFormsBundle; | ||
use Ibexa\Bundle\DesignEngine\IbexaDesignEngineBundle; | ||
use Ibexa\Bundle\Rest\IbexaRestBundle; | ||
use Ibexa\Bundle\Search\IbexaSearchBundle; | ||
use Ibexa\Bundle\Test\Rest\IbexaTestRestBundle; | ||
use Ibexa\Bundle\User\IbexaUserBundle; | ||
use Ibexa\Contracts\Core\Repository\BookmarkService; | ||
use Ibexa\Contracts\Test\Core\IbexaTestKernel; | ||
use Ibexa\Rest\Server\Controller\JWT; | ||
use Knp\Bundle\MenuBundle\KnpMenuBundle; | ||
use Swift_Mailer; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\Config\Resource\FileResource; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Yaml\Yaml; | ||
use Symfony\WebpackEncoreBundle\WebpackEncoreBundle; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class AdminUiIbexaTestKernel extends IbexaTestKernel | ||
{ | ||
public function registerBundles(): iterable | ||
{ | ||
yield from parent::registerBundles(); | ||
|
||
yield new HautelookTemplatedUriBundle(); | ||
yield new KnpMenuBundle(); | ||
yield new WebpackEncoreBundle(); | ||
|
||
yield new IbexaContentFormsBundle(); | ||
yield new IbexaDesignEngineBundle(); | ||
yield new IbexaRestBundle(); | ||
yield new IbexaSearchBundle(); | ||
yield new IbexaTestRestBundle(); | ||
yield new IbexaUserBundle(); | ||
|
||
yield new IbexaAdminUiBundle(); | ||
} | ||
|
||
protected static function getExposedServicesByClass(): iterable | ||
{ | ||
yield from parent::getExposedServicesByClass(); | ||
|
||
yield BookmarkService::class; | ||
} | ||
|
||
public function registerContainerConfiguration(LoaderInterface $loader): void | ||
{ | ||
parent::registerContainerConfiguration($loader); | ||
|
||
$loader->load(static function (ContainerBuilder $container): void { | ||
self::configureIbexaBundles($container); | ||
self::configureThirdPartyBundles($container); | ||
}); | ||
} | ||
|
||
private static function configureIbexaBundles(ContainerBuilder $container): void | ||
{ | ||
// REST | ||
$resource = new FileResource(__DIR__ . '/Resources/routing.yaml'); | ||
$container->addResource($resource); | ||
$container->loadFromExtension('framework', [ | ||
'router' => [ | ||
'resource' => $resource->getResource(), | ||
], | ||
]); | ||
self::addSyntheticService($container, JWT::class); | ||
|
||
$configFileName = __DIR__ . '/Resources/ibexa_test_config.yaml'; | ||
$resource = new FileResource($configFileName); | ||
$container->addResource($resource); | ||
|
||
$extensionConfig = Yaml::parseFile($resource->getResource()); | ||
foreach ($extensionConfig as $extensionName => $config) { | ||
$container->loadFromExtension($extensionName, $config); | ||
} | ||
} | ||
|
||
private static function configureThirdPartyBundles(ContainerBuilder $container): void | ||
{ | ||
$container->loadFromExtension('webpack_encore', [ | ||
'output_path' => dirname(__DIR__, 2) . '/var/encore/output', | ||
]); | ||
|
||
self::addSyntheticService($container, Swift_Mailer::class); | ||
|
||
// bazinga's locale_fallback | ||
$container->setParameter('locale_fallback', 'en'); | ||
|
||
// Symfony | ||
$container->setParameter('form.type_extension.csrf.enabled', false); | ||
} | ||
} |
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": [] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.