Skip to content

Commit eed2024

Browse files
committed
Add coverage
1 parent 8df42e8 commit eed2024

64 files changed

Lines changed: 7596 additions & 29 deletions

File tree

Some content is hidden

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

.github/workflows/test-application.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ on:
88
- '[0-9]+.[0-9]+'
99
workflow_dispatch:
1010

11+
env:
12+
CI_GROUP_OUTPUT: true
13+
1114
concurrency:
1215
group: ${{ github.workflow }}-${{ github.ref }}
1316
cancel-in-progress: true
@@ -56,6 +59,16 @@ jobs:
5659
SYMFONY_DEPRECATIONS_HELPER: weak
5760
DATABASE_URL: mysql://root:ChangeMe@127.0.0.1:3306/sulu_test?serverVersion=8.0&charset=utf8mb4
5861

62+
- php-version: '8.5'
63+
database: mysql-84
64+
dependency-versions: 'highest'
65+
php-extensions: 'ctype, iconv, mysql, gd'
66+
tools: 'composer:snapshot'
67+
composer-stability: 'dev'
68+
env:
69+
SYMFONY_DEPRECATIONS_HELPER: weak
70+
DATABASE_URL: mysql://root:ChangeMe@127.0.0.1:3306/sulu_test?serverVersion=8.4&charset=utf8mb4
71+
5972
steps:
6073
- name: Checkout project
6174
uses: actions/checkout@v4
@@ -72,6 +85,15 @@ jobs:
7285
ini-values: memory_limit=-1
7386
coverage: none
7487

88+
- name: Remove Lint Tools
89+
# These tools are not required to run tests, so we are removing them to improve dependency resolving and
90+
# testing lowest versions.
91+
run: composer remove "*php-cs-fixer*" "*phpstan*" "*rector*" --dev --no-update
92+
93+
- name: Set composer stability
94+
if: ${{ matrix.composer-stability }}
95+
run: composer config minimum-stability ${{ matrix.composer-stability }}
96+
7597
- name: Install composer dependencies
7698
uses: ramsey/composer-install@v3
7799
with:
@@ -85,6 +107,53 @@ jobs:
85107
run: composer test
86108
env: ${{ matrix.env }}
87109

110+
php-lint:
111+
name: "PHP Lint"
112+
runs-on: ubuntu-22.04
113+
timeout-minutes: 30
114+
115+
env:
116+
APP_ENV: test
117+
APP_SECRET: a448d1dfcaa563fce56c2fd9981f662b
118+
MAILER_URL: null://localhost
119+
SULU_ADMIN_EMAIL:
120+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121+
122+
steps:
123+
- name: Checkout project
124+
uses: actions/checkout@v4
125+
126+
- name: Install and configure PHP
127+
uses: shivammathur/setup-php@v2
128+
with:
129+
php-version: '8.3'
130+
extensions: 'ctype, iconv, mysql'
131+
tools: 'composer:v2'
132+
ini-values: memory_limit=-1
133+
coverage: none
134+
135+
- name: Install composer dependencies
136+
uses: ramsey/composer-install@v3
137+
with:
138+
dependency-versions: highest
139+
140+
- name: Output versions and installed dependencies
141+
run: |
142+
echo 'PHP Version:'
143+
php --version
144+
echo ''
145+
echo 'PHP Modules:'
146+
php -m
147+
echo ''
148+
echo 'Composer Info:'
149+
composer info
150+
echo ''
151+
echo 'Composer Lock:'
152+
cat composer.lock
153+
154+
- name: Lint code
155+
run: composer lint
156+
88157
php-coverage:
89158
name: "PHP Coverage"
90159
runs-on: ubuntu-22.04

composer.json

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,24 @@
66
"require": {
77
"php": "^8.2",
88
"cmsig/seal": "^0.12",
9-
"doctrine/collections": "^2.0",
10-
"doctrine/orm": "^3.0",
9+
"doctrine/collections": "^1.6 || ^2.0",
10+
"doctrine/dbal": "^3.9 || ^4.0",
11+
"doctrine/orm": "^2.17.3 || ^3.3",
1112
"sulu/messenger": "^1.0",
1213
"sulu/sulu": "~3.0",
13-
"symfony/config": "^7.0",
14-
"symfony/dependency-injection": "^7.0",
15-
"symfony/event-dispatcher": "^7.0",
16-
"symfony/http-foundation": "^7.0",
17-
"symfony/http-kernel": "^7.0",
18-
"symfony/messenger": "^7.0",
19-
"symfony/routing": "^7.0",
20-
"symfony/security-core": "^7.0",
21-
"symfony/serializer": "^7.0",
14+
"symfony/config": "^6.4 || ^7.1",
15+
"symfony/dependency-injection": "^6.4 || ^7.1",
16+
"symfony/event-dispatcher": "^6.4 || ^7.1",
17+
"symfony/http-foundation": "^6.4 || ^7.1",
18+
"symfony/http-kernel": "^6.4 || ^7.1",
19+
"symfony/messenger": "^6.4 || ^7.1",
20+
"symfony/routing": "^6.4 || ^7.1",
21+
"symfony/security-core": "^6.4 || ^7.1",
22+
"symfony/serializer": "^6.4 || ^7.1",
2223
"symfony/translation-contracts": "^3.0",
23-
"symfony/uid": "^7.0",
24+
"symfony/uid": "^6.4 || ^7.1",
2425
"twig/twig": "^3.0",
25-
"webmozart/assert": "^1.0"
26+
"webmozart/assert": "^1.0 || ^2.0"
2627
},
2728
"require-dev": {
2829
"ext-filter": "*",
@@ -38,12 +39,12 @@
3839
"phpstan/phpstan-webmozart-assert": "^2.0",
3940
"phpunit/phpunit": "^11.0",
4041
"rector/rector": "^2.0",
41-
"shipmonk/composer-dependency-analyser": "^1.0",
42+
"shipmonk/composer-dependency-analyser": "^1.8",
4243
"spaze/phpstan-disallowed-calls": "^4.7",
43-
"symfony/browser-kit": "^8.0",
44-
"symfony/console": "^7.0",
45-
"symfony/dotenv": "^7.0",
46-
"symfony/framework-bundle": "^7.0",
44+
"symfony/browser-kit": "^6.4 || ^7.1",
45+
"symfony/console": "^6.4 || ^7.1",
46+
"symfony/dotenv": "^6.4 || ^7.1",
47+
"symfony/framework-bundle": "^6.4 || ^7.1",
4748
"cmsig/seal-memory-adapter": "^0.12.10"
4849
},
4950
"autoload": {
@@ -65,7 +66,7 @@
6566
],
6667
"test": "@php vendor/bin/phpunit",
6768
"test-with-coverage": "@php vendor/bin/phpunit --coverage-php tests/reports/coverage.php --coverage-html tests/reports/html --log-junit tests/reports/junit.xml",
68-
"check-coverage": "@php vendor/bin/code-coverage-checker \"tests/reports/coverage.php\" \"line\" \"100.00\"",
69+
"check-coverage": "@php vendor/bin/code-coverage-checker \"tests/reports/coverage.php\" \"line\" \"100.00\" \"src\"",
6970
"lint": [
7071
"@lint-composer",
7172
"@lint-composer-dependencies",
@@ -96,7 +97,7 @@
9697
"@php vendor/bin/rector process"
9798
],
9899
"lint-composer": "@composer validate --strict",
99-
"lint-composer-dependencies": "@php vendor/bin/composer-dependency-analyser",
100+
"lint-composer-dependencies": "@php vendor/bin/composer-dependency-analyser --show-all-usages",
100101
"lint-doctrine": "@php tests/Application/bin/console.php doctrine:schema:validate --skip-sync --env test",
101102
"lint-container": "@php tests/Application/bin/console.php lint:container --env test",
102103
"lint-yaml": "@php tests/Application/bin/console.php lint:yaml tests/Application/config --env test"

src/UserInterface/Controller/Admin/ProductDetailsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private function getData(Request $request): array
157157
private function serializeProduct(?ProductInterface $product, string $locale): array
158158
{
159159
if (null === $product) {
160-
return [];
160+
return []; // @codeCoverageIgnore
161161
}
162162

163163
$translation = $product->getTranslation($locale);
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of Sulu.
7+
*
8+
* (c) Sulu GmbH
9+
*
10+
* This source file is subject to the MIT license that is bundled
11+
* with this source code in the file LICENSE.
12+
*/
13+
14+
namespace Sulu\Product\Tests\Functional\HttpKernel;
15+
16+
use Sulu\Bundle\TestBundle\Testing\SuluTestCase;
17+
use Sulu\Product\Domain\Repository\ProductRepositoryInterface;
18+
use Sulu\Product\Infrastructure\Symfony\HttpKernel\SuluProductBundle;
19+
20+
class SuluProductBundleTest extends SuluTestCase
21+
{
22+
protected function tearDown(): void
23+
{
24+
parent::tearDown();
25+
\restore_exception_handler();
26+
}
27+
28+
public function testContainerRegistersRepositories(): void
29+
{
30+
self::bootKernel();
31+
$container = self::getContainer();
32+
33+
$this->assertTrue($container->has(ProductRepositoryInterface::class));
34+
}
35+
36+
public function testContainerRegistersProductMappers(): void
37+
{
38+
self::bootKernel();
39+
$container = self::getContainer();
40+
41+
$this->assertTrue($container->has('sulu_product.product_details_mapper'));
42+
}
43+
44+
public function testBundleClassExists(): void
45+
{
46+
$this->assertTrue(\class_exists(SuluProductBundle::class));
47+
}
48+
}

0 commit comments

Comments
 (0)