Skip to content

Commit 8b36cde

Browse files
[Export] Fix and test serializations
1 parent 39ffca6 commit 8b36cde

File tree

12 files changed

+691
-34
lines changed

12 files changed

+691
-34
lines changed

.github/workflows/build.yaml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ jobs:
1111
tests:
1212
runs-on: ubuntu-latest
1313

14-
name: "PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}"
14+
name: "PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"
1515

1616
strategy:
1717
fail-fast: false
1818
matrix:
1919
php: ["8.3"]
2020
symfony: ["^6.4", "^7.3"]
21+
mysql: ["8.4"]
2122

2223
env:
23-
APP_ENV: test
24+
APP_ENV: test_minimal
25+
DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}"
2426

2527
steps:
2628
-
@@ -35,6 +37,17 @@ jobs:
3537
tools: symfony
3638
coverage: none
3739

40+
-
41+
name: Shutdown default MySQL
42+
run: sudo service mysql stop
43+
44+
-
45+
name: Setup MySQL
46+
uses: mirromutth/mysql-action@v1.1
47+
with:
48+
mysql version: "${{ matrix.mysql }}"
49+
mysql root password: "root"
50+
3851
-
3952
name: Get Composer cache directory
4053
id: composer-cache
@@ -74,6 +87,24 @@ jobs:
7487
name: Run PHPStan
7588
run: vendor/bin/phpstan analyse
7689

77-
# -
78-
# name: Run PHPUnit
79-
# run: vendor/bin/phpunit --colors=always
90+
-
91+
name: Warmup cache
92+
run: vendor/bin/console cache:warmup
93+
94+
-
95+
name: Validate container
96+
run: vendor/bin/console lint:container
97+
98+
-
99+
name: Warmup cache
100+
run: vendor/bin/console cache:warmup
101+
102+
-
103+
name: Setup database
104+
run: |
105+
vendor/bin/console doctrine:database:create
106+
vendor/bin/console doctrine:schema:create
107+
108+
-
109+
name: Run PHPUnit
110+
run: vendor/bin/phpunit --testsuite=functional --colors=always

composer.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
"Sylius\\ImportExport\\": "src/"
1111
}
1212
},
13+
"autoload-dev": {
14+
"psr-4": {
15+
"Tests\\Sylius\\ImportExport\\": [
16+
"tests/",
17+
"tests/TestApplication/src/"
18+
]
19+
}
20+
},
1321
"require": {
1422
"php": "^8.2",
1523
"doctrine/orm": "^2.18 || ^3.3",
@@ -24,12 +32,12 @@
2432
"symfony/uid": "^6.4 || ^7.3"
2533
},
2634
"require-dev": {
35+
"phpstan/phpstan": "^1.12",
36+
"phpstan/phpstan-doctrine": "^1.5",
2737
"phpunit/phpunit": "^10.5",
28-
"webmozart/assert": "^1.11",
2938
"sylius-labs/coding-standard": "^4.4",
3039
"sylius/test-application": "*",
31-
"phpstan/phpstan": "^1.12",
32-
"phpstan/phpstan-doctrine": "^1.5"
40+
"webmozart/assert": "^1.11"
3341
},
3442
"config": {
3543
"allow-plugins": {

ecs.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
return function (ECSConfig $ecsConfig): void {
1010
$ecsConfig->paths([
1111
__DIR__ . '/src',
12+
__DIR__ . '/tests/Functional',
13+
__DIR__ . '/tests/TestApplication/src',
1214
]);
1315

1416
$ecsConfig->import('vendor/sylius-labs/coding-standard/ecs.php');

phpunit.xml.dist

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
5-
colors="true"
6-
bootstrap="tests/Application/config/bootstrap.php">
3+
<phpunit
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
6+
colors="true"
7+
bootstrap="vendor/sylius/test-application/config/bootstrap.php"
8+
>
79
<testsuites>
8-
<testsuite name="AcmeSyliusExamplePlugin Test Suite">
9-
<directory>tests/Integration</directory>
10-
<directory>tests/Api</directory>
11-
<directory>tests/Unit</directory>
10+
<testsuite name="functional">
11+
<directory>tests/Functional</directory>
1212
</testsuite>
1313
</testsuites>
1414

1515
<php>
1616
<ini name="error_reporting" value="-1" />
1717

18-
<server name="KERNEL_CLASS_PATH" value="/tests/Application/Kernel.php" />
18+
<server name="KERNEL_CLASS" value="Sylius\TestApplication\Kernel" />
1919
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />
20-
<env name="APP_ENV" value="test"/>
20+
21+
<env name="APP_ENV" value="test_minimal" />
2122
<env name="SHELL_VERBOSITY" value="-1" />
2223
</php>
2324
</phpunit>

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private function addExportConfiguration(ArrayNodeDefinition $node): void
5959
->end()
6060
->children()
6161
->scalarNode('serialization_group')
62-
->isRequired()
62+
->cannotBeEmpty()
6363
->defaultValue(DefaultSerializationGroups::EXPORT_GROUP)
6464
->end()
6565
->scalarNode('provider')

src/Provider/ResourceData/GridResourceDataProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function getData(MetadataInterface $resource, string $gridCode, array $re
6060
/** @phpstan-ignore-next-line */
6161
return $this->serializer->normalize($rawData, context: [
6262
ExportAwareItemNormalizer::EXPORT_CONTEXT_KEY => true,
63-
'groups' => $parameters['serialization_groups'], [DefaultSerializationGroups::EXPORT_GROUP],
63+
'groups' => $parameters['serialization_groups'] ?? [DefaultSerializationGroups::EXPORT_GROUP],
6464
]);
6565
}
6666
}

0 commit comments

Comments
 (0)