Skip to content

Commit d61cf88

Browse files
[CI] Renamed integration tests to functional and configured integration tests (#68)
For more details see #68 Key changes: * [CI] Renamed REST integration tests to REST functional tests * [Tests] Configured integration test suite * [Tests] Created basic integration test --------- Co-Authored-By: Konrad Oboza <[email protected]>
1 parent 0d5375d commit d61cf88

File tree

10 files changed

+148
-6
lines changed

10 files changed

+148
-6
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: composer run-script check-cs -- --format=checkstyle | cs2pr
3535

3636
tests:
37-
name: Unit tests
37+
name: Unit & integration tests
3838
runs-on: "ubuntu-20.04"
3939
timeout-minutes: 15
4040

@@ -66,6 +66,8 @@ jobs:
6666

6767
- name: Run unit test suite
6868
run: composer test
69-
integration-tests:
70-
name: "REST integration tests"
69+
- name: Run integration test suite
70+
run: composer test-integration
71+
functional-tests:
72+
name: "REST functional tests"
7173
uses: ./.github/workflows/integration-tests-callable.yaml

.github/workflows/integration-tests-callable.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111
WEB_HOST: web
1212

1313
jobs:
14-
integration-tests-rest:
14+
functional-tests-rest:
1515
runs-on: ubuntu-latest
1616
timeout-minutes: 15
1717

@@ -51,4 +51,4 @@ jobs:
5151
- name: Run tests
5252
run: |
5353
cd "$HOME/build/project"
54-
docker-compose --env-file=.env exec -T --user www-data app sh -c "cd vendor/ibexa/rest && composer update && composer integration"
54+
docker-compose --env-file=.env exec -T --user www-data app sh -c "cd vendor/ibexa/rest && composer update && composer test-functional"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/.php_cs.cache
33
.php-cs-fixer.cache
44
composer.lock
5+
/.phpunit.result.cache
6+
/var

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"ibexa/ci-scripts": "^0.2@dev",
5050
"ibexa/doctrine-schema": "~4.5.0@dev",
5151
"ibexa/code-style": "^1.0",
52+
"ibexa/test-core": "^0.1.x-dev",
5253
"friendsofphp/php-cs-fixer": "^3.0",
5354
"phpunit/phpunit": "^8.5",
5455
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
@@ -68,7 +69,8 @@
6869
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
6970
"check-cs": "@fix-cs --dry-run",
7071
"test": "phpunit -c phpunit.xml",
71-
"integration": "phpunit -c phpunit-integration-rest.xml"
72+
"test-integration": "phpunit -c phpunit.integration.xml",
73+
"test-functional": "phpunit -c phpunit.functional.xml"
7274
},
7375
"extra": {
7476
"branch-alias": {
File renamed without changes.

phpunit.integration.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
3+
bootstrap="tests/integration/bootstrap.php"
4+
beStrictAboutOutputDuringTests="true"
5+
beStrictAboutTodoAnnotatedTests="true"
6+
failOnWarning="true"
7+
verbose="true">
8+
<php>
9+
<env name="KERNEL_CLASS" value="Ibexa\Tests\Integration\Rest\IbexaTestKernel" />
10+
<env name="SEARCH_ENGINE" value="legacy" />
11+
<env name="DATABASE_URL" value="sqlite://i@i/var/test.db" />
12+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=4&amp;max[direct]=0&amp;verbose=0"/>
13+
</php>
14+
<testsuites>
15+
<testsuite name="integration">
16+
<directory>tests/integration</directory>
17+
</testsuite>
18+
</testsuites>
19+
</phpunit>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Tests\Integration\Rest;
10+
11+
use Ibexa\Contracts\Core\Repository\Repository;
12+
use Ibexa\Contracts\Test\Core\IbexaKernelTestCase;
13+
use Ibexa\Rest\Server\Controller\Root as RestRootController;
14+
15+
/**
16+
* @coversNothing
17+
*/
18+
final class BasicKernelTest extends IbexaKernelTestCase
19+
{
20+
protected function setUp(): void
21+
{
22+
self::bootKernel();
23+
}
24+
25+
public function testBasicKernelCompiles(): void
26+
{
27+
$this->getIbexaTestCore()->getServiceByClassName(Repository::class);
28+
$this->getIbexaTestCore()->getServiceByClassName(RestRootController::class);
29+
$this->expectNotToPerformAssertions();
30+
}
31+
32+
public function testRouterIsAvailable(): void
33+
{
34+
$router = self::getContainer()->get('router');
35+
$router->match('/api/ibexa/v2/');
36+
$this->expectNotToPerformAssertions();
37+
}
38+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Tests\Integration\Rest;
10+
11+
use Hautelook\TemplatedUriBundle\HautelookTemplatedUriBundle;
12+
use Ibexa\Bundle\Rest\IbexaRestBundle;
13+
use Ibexa\Contracts\Test\Core\IbexaTestKernel as CoreIbexaTestKernel;
14+
use Ibexa\Rest\Server\Controller\Root as RestRootController;
15+
use Lexik\Bundle\JWTAuthenticationBundle\Services\JWTTokenManagerInterface;
16+
use Symfony\Component\Config\Loader\LoaderInterface;
17+
use Symfony\Component\DependencyInjection\ContainerBuilder;
18+
19+
final class IbexaTestKernel extends CoreIbexaTestKernel
20+
{
21+
public function registerBundles(): iterable
22+
{
23+
yield from parent::registerBundles();
24+
25+
yield new HautelookTemplatedUriBundle();
26+
yield new IbexaRestBundle();
27+
}
28+
29+
public function registerContainerConfiguration(LoaderInterface $loader): void
30+
{
31+
parent::registerContainerConfiguration($loader);
32+
33+
$loader->load(static function (ContainerBuilder $container): void {
34+
self::addSyntheticService($container, JWTTokenManagerInterface::class);
35+
36+
self::loadRouting($container);
37+
});
38+
}
39+
40+
protected static function getExposedServicesByClass(): iterable
41+
{
42+
yield from parent::getExposedServicesByClass();
43+
yield RestRootController::class;
44+
}
45+
46+
private static function loadRouting(ContainerBuilder $container): void
47+
{
48+
$container->loadFromExtension('framework', [
49+
'router' => [
50+
'resource' => __DIR__ . '/Resources/test_routing.yaml',
51+
],
52+
]);
53+
}
54+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test.ibexa.rest:
2+
resource: '@IbexaRestBundle/Resources/config/routing.yml'
3+
prefix: '%ibexa.rest.path_prefix%'

tests/integration/bootstrap.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
use Ibexa\Tests\Integration\Rest\IbexaTestKernel;
10+
use Symfony\Bundle\FrameworkBundle\Console\Application;
11+
12+
chdir(dirname(__DIR__, 2));
13+
14+
$kernel = new IbexaTestKernel('test', true);
15+
$kernel->boot();
16+
17+
$application = new Application($kernel);
18+
$application->setAutoExit(false);
19+
20+
// Skipping database initialization until really needed by integration tests
21+
22+
$kernel->shutdown();

0 commit comments

Comments
 (0)