Skip to content

Commit

Permalink
Merged branch '4.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
alongosz committed Jul 28, 2023
2 parents f4ca3f5 + d61cf88 commit d201149
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 6 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: composer run-script check-cs -- --format=checkstyle | cs2pr

tests:
name: Unit tests
name: Unit & integration tests
runs-on: "ubuntu-20.04"
timeout-minutes: 15

Expand Down Expand Up @@ -66,6 +66,8 @@ jobs:

- name: Run unit test suite
run: composer test
integration-tests:
name: "REST integration tests"
- name: Run integration test suite
run: composer test-integration
functional-tests:
name: "REST functional tests"
uses: ./.github/workflows/integration-tests-callable.yaml
4 changes: 2 additions & 2 deletions .github/workflows/integration-tests-callable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
WEB_HOST: web

jobs:
integration-tests-rest:
functional-tests-rest:
runs-on: ubuntu-latest
timeout-minutes: 15

Expand Down Expand Up @@ -51,4 +51,4 @@ jobs:
- name: Run tests
run: |
cd "$HOME/build/project"
docker-compose --env-file=.env exec -T --user www-data app sh -c "cd vendor/ibexa/rest && composer update && composer integration"
docker-compose --env-file=.env exec -T --user www-data app sh -c "cd vendor/ibexa/rest && composer update && composer test-functional"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
/.php_cs.cache
.php-cs-fixer.cache
composer.lock
/.phpunit.result.cache
/var
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"ibexa/ci-scripts": "^0.2@dev",
"ibexa/doctrine-schema": "~4.6.0@dev",
"ibexa/code-style": "^1.0",
"ibexa/test-core": "^0.1.x-dev",
"friendsofphp/php-cs-fixer": "^3.0",
"phpunit/phpunit": "^8.5",
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
Expand All @@ -68,7 +69,8 @@
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
"check-cs": "@fix-cs --dry-run",
"test": "phpunit -c phpunit.xml",
"integration": "phpunit -c phpunit-integration-rest.xml"
"test-integration": "phpunit -c phpunit.integration.xml",
"test-functional": "phpunit -c phpunit.functional.xml"
},
"extra": {
"branch-alias": {
Expand Down
File renamed without changes.
19 changes: 19 additions & 0 deletions phpunit.integration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.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\Rest\IbexaTestKernel" />
<env name="SEARCH_ENGINE" value="legacy" />
<env name="DATABASE_URL" value="sqlite://i@i/var/test.db" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=4&amp;max[direct]=0&amp;verbose=0"/>
</php>
<testsuites>
<testsuite name="integration">
<directory>tests/integration</directory>
</testsuite>
</testsuites>
</phpunit>
38 changes: 38 additions & 0 deletions tests/integration/BasicKernelTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?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\Rest;

use Ibexa\Contracts\Core\Repository\Repository;
use Ibexa\Contracts\Test\Core\IbexaKernelTestCase;
use Ibexa\Rest\Server\Controller\Root as RestRootController;

/**
* @coversNothing
*/
final class BasicKernelTest extends IbexaKernelTestCase
{
protected function setUp(): void
{
self::bootKernel();
}

public function testBasicKernelCompiles(): void
{
$this->getIbexaTestCore()->getServiceByClassName(Repository::class);
$this->getIbexaTestCore()->getServiceByClassName(RestRootController::class);
$this->expectNotToPerformAssertions();
}

public function testRouterIsAvailable(): void
{
$router = self::getContainer()->get('router');
$router->match('/api/ibexa/v2/');
$this->expectNotToPerformAssertions();
}
}
54 changes: 54 additions & 0 deletions tests/integration/IbexaTestKernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?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\Rest;

use Hautelook\TemplatedUriBundle\HautelookTemplatedUriBundle;
use Ibexa\Bundle\Rest\IbexaRestBundle;
use Ibexa\Contracts\Test\Core\IbexaTestKernel as CoreIbexaTestKernel;
use Ibexa\Rest\Server\Controller\Root as RestRootController;
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

final class IbexaTestKernel extends CoreIbexaTestKernel
{
public function registerBundles(): iterable
{
yield from parent::registerBundles();

yield new HautelookTemplatedUriBundle();
yield new IbexaRestBundle();
}

public function registerContainerConfiguration(LoaderInterface $loader): void
{
parent::registerContainerConfiguration($loader);

$loader->load(static function (ContainerBuilder $container): void {
self::addSyntheticService($container, JWTTokenManagerInterface::class);

self::loadRouting($container);
});
}

protected static function getExposedServicesByClass(): iterable
{
yield from parent::getExposedServicesByClass();
yield RestRootController::class;
}

private static function loadRouting(ContainerBuilder $container): void
{
$container->loadFromExtension('framework', [
'router' => [
'resource' => __DIR__ . '/Resources/test_routing.yaml',
],
]);
}
}
3 changes: 3 additions & 0 deletions tests/integration/Resources/test_routing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test.ibexa.rest:
resource: '@IbexaRestBundle/Resources/config/routing.yml'
prefix: '%ibexa.rest.path_prefix%'
22 changes: 22 additions & 0 deletions tests/integration/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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);

use Ibexa\Tests\Integration\Rest\IbexaTestKernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

chdir(dirname(__DIR__, 2));

$kernel = new IbexaTestKernel('test', true);
$kernel->boot();

$application = new Application($kernel);
$application->setAutoExit(false);

// Skipping database initialization until really needed by integration tests

$kernel->shutdown();

0 comments on commit d201149

Please sign in to comment.