Skip to content

Commit ae7f8a0

Browse files
committed
fix: phpunit files
1 parent b552f03 commit ae7f8a0

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ vendor/
88
.php_cs.cache
99
.php-cs-fixer.cache
1010
.phpunit.result.cache
11+
phpunit.xml

phpunit.xml.dist

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
5-
backupGlobals="false"
6-
colors="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
stopOnFailure="false"
11-
bootstrap="./vendor/autoload.php">
12-
<testsuites>
13-
<testsuite name="Linio Framework Test Suite">
14-
<directory suffix="Test.php">tests</directory>
15-
</testsuite>
16-
</testsuites>
17-
<filter>
18-
<whitelist addUncoveredFilesFromWhitelist="true">
19-
<directory suffix=".php">src</directory>
20-
<exclude>
21-
<directory suffix=".php">vendor</directory>
22-
</exclude>
23-
</whitelist>
24-
</filter>
25-
<logging>
26-
<log type="coverage-clover" target="./coverage.xml"/>
27-
</logging>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnFailure="false" bootstrap="./vendor/autoload.php">
3+
<coverage includeUncoveredFiles="true">
4+
<include>
5+
<directory suffix=".php">src</directory>
6+
</include>
7+
<exclude>
8+
<directory suffix=".php">vendor</directory>
9+
</exclude>
10+
<report>
11+
<clover outputFile="./coverage.xml"/>
12+
</report>
13+
</coverage>
14+
<testsuites>
15+
<testsuite name="Linio Framework Test Suite">
16+
<directory suffix="Test.php">tests</directory>
17+
</testsuite>
18+
</testsuites>
19+
<logging/>
2820
</phpunit>

src/Form/FormFactory.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Symfony\Component\Form\FormBuilderInterface;
1616
use Symfony\Component\Form\FormFactory as SymfonyFormFactory;
1717
use Symfony\Component\Form\FormInterface;
18+
use Symfony\Component\Validator\Mapping\ClassMetadata;
19+
use Symfony\Component\Validator\Mapping\GenericMetadata;
1820
use Symfony\Component\Validator\Validation;
1921

2022
class FormFactory
@@ -220,7 +222,11 @@ public function createValidator($key, mixed $object)
220222
}
221223

222224
foreach ($fieldConfiguration['validation'] as $validatorName => $options) {
223-
$metadata->addPropertyConstraint($key, new $validatorName($options));
225+
if ($metadata instanceof ClassMetadata) {
226+
$metadata->addPropertyConstraint($key, new $validatorName($options));
227+
} elseif ($metadata instanceof GenericMetadata) {
228+
$metadata->addConstraint(new $validatorName($options));
229+
}
224230
}
225231
}
226232

0 commit comments

Comments
 (0)