Skip to content

Commit 1f4d518

Browse files
authored
Added integration tests as a simple standalone Symfony project (#48)
* Moved tests to Unit namespace * Added integration tests as a simple standalone Symfony project * Add link from README to integration test suite * Do not require symfony/symfony in GitHub actions * Fixed error in composer.json
1 parent 67b5a6f commit 1f4d518

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+391
-80
lines changed

.github/workflows/tests.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ jobs:
3535

3636
- name: "Install dependencies with composer"
3737
run: |
38-
composer require --no-update --dev symfony/symfony:${{ matrix.symfony-version }}
39-
composer update --no-interaction --no-progress --no-suggest
38+
composer require --no-update symfony/framework-bundle:${{ matrix.symfony-version }}
39+
composer require --no-update --dev symfony/form:${{ matrix.symfony-version }}
40+
composer require --no-update --dev symfony/twig-bundle:${{ matrix.symfony-version }}
41+
composer require --no-update --dev symfony/validator:${{ matrix.symfony-version }}
42+
composer require --no-update --dev symfony/translation:${{ matrix.symfony-version }}
43+
composer require --no-update --dev symfony/yaml:${{ matrix.symfony-version }}
44+
composer update --no-interaction --no-progress
4045
4146
- name: "Run tests with phpunit/phpunit"
4247
run: vendor/bin/phpunit
@@ -61,7 +66,7 @@ jobs:
6166
php-version: ${{ matrix.php-version }}
6267

6368
- name: "Install dependencies with composer"
64-
run: composer update --no-interaction --no-progress --no-suggest
69+
run: composer update --no-interaction --no-progress
6570

6671
- name: "Run tests with phpunit/phpunit"
6772
env:
@@ -92,7 +97,7 @@ jobs:
9297
php-version: ${{ matrix.php-version }}
9398

9499
- name: "Install dependencies with composer"
95-
run: composer update --no-interaction --no-progress --no-suggest
100+
run: composer update --no-interaction --no-progress
96101

97102
- name: "Run checkstyle with squizlabs/php_codesniffer"
98103
run: vendor/bin/phpcs

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.idea/
2+
/tests/Integration/var/
23
/vendor/
34
/.phpcs-cache
45
/.phpunit.result.cache

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ status.disabled: Désactivé
177177

178178
## More examples
179179

180-
See examples from [test suite](tests/Fixtures) & associated [tests](tests/EnumsFromFixturesTest.php).
180+
See examples from [unit test suite](tests/Unit/Fixtures) & associated [tests](tests/Unit/EnumsFromFixturesTest.php).
181+
182+
See example Symfony project in [integration test suite](tests/Integration).
181183

182184

183185
## Recipes

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
"phpunit/phpunit": "^9.4",
2121
"squizlabs/php_codesniffer": "^3.5",
2222
"symfony/form": "^4.4|^5.0",
23+
"symfony/translation": "^4.4|^5.0",
2324
"symfony/twig-bundle": "^4.4|^5.0",
2425
"symfony/validator": "^4.4|^5.0",
26+
"symfony/yaml": "^4.4|^5.0",
2527
"twig/twig": "^2.0|^3.0"
2628
},
2729
"suggest": {
@@ -35,7 +37,11 @@
3537
"psr-4": { "Yokai\\EnumBundle\\": "src" }
3638
},
3739
"autoload-dev": {
38-
"psr-4": { "Yokai\\EnumBundle\\Tests\\": "tests" }
40+
"psr-4": {
41+
"Yokai\\EnumBundle\\Tests\\Unit\\": "tests/Unit",
42+
"Yokai\\EnumBundle\\Tests\\Integration\\App\\": "tests/Integration/src",
43+
"Yokai\\EnumBundle\\Tests\\Integration\\": "tests/Integration/tests"
44+
}
3945
},
4046
"minimum-stability": "stable",
4147
"extra": {

phpcs.xml.dist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
<rule ref="PSR12"/>
1212

1313
<file>src/</file>
14-
<file>tests/</file>
14+
<file>tests/Integration/src/</file>
15+
<file>tests/Integration/tests/</file>
16+
<file>tests/Unit/</file>
1517

1618
<rule ref="Generic.PHP.ForbiddenFunctions">
1719
<properties>

phpunit.xml.dist

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
4-
backupGlobals="false"
5-
backupStaticAttributes="false"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
114
colors="true"
125
bootstrap="vendor/autoload.php">
6+
<php>
7+
<server name="KERNEL_CLASS" value="Yokai\EnumBundle\Tests\Integration\App\Kernel"/>
8+
</php>
9+
1310
<testsuites>
14-
<testsuite name="YokaiEnumBundle Test Suite">
15-
<directory>./tests</directory>
11+
<testsuite name="Unit">
12+
<directory>./tests/Unit</directory>
13+
</testsuite>
14+
<testsuite name="Integration">
15+
<directory>./tests/Integration/tests</directory>
1616
</testsuite>
1717
</testsuites>
1818
<coverage>

src/DependencyInjection/EnumExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function load(array $configs, ContainerBuilder $container): void
5656
}
5757
if ($requiresTwig) {
5858
$container->register('yokai_enum.twig_extension.enum_extension', EnumTwigExtension::class)
59-
->setArgument('$enumRegistry', $registry)
59+
->setArgument('$registry', $registry)
6060
->addTag('twig.extension');
6161
}
6262

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
framework: ~
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
framework:
2+
default_locale: en
3+
translator:
4+
default_path: '%kernel.project_dir%/translations'
5+
fallbacks:
6+
- en
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
_defaults:
3+
autowire: true
4+
autoconfigure: true
5+
6+
Yokai\EnumBundle\Tests\Integration\App\:
7+
resource: '../src/'
8+
exclude:
9+
- '../src/Model/'

0 commit comments

Comments
 (0)