From b01811a5f6f4948d79466268f8fd42da9c37af8d Mon Sep 17 00:00:00 2001 From: craig410 Date: Tue, 13 Feb 2024 12:24:31 +0000 Subject: [PATCH 1/4] Test to ensure validation annotations are being read and validated --- .github/workflows/test.yaml | 6 ++++- composer.json | 14 ++++++----- phpunit.xml | 3 +++ .../SymfonyValidatorAnnotationTest.php | 25 +++++++++++++++++++ 4 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 test/integration/SymfonyValidatorAnnotationTest.php diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index bd9275f..a1e9c95 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -59,4 +59,8 @@ jobs: - name: Run unit tests run: | - vendor/bin/phpunit + vendor/bin/phpunit --testsuite=Unit + + - name: Run integration tests + run: | + vendor/bin/phpunit --testsuite=Integration diff --git a/composer.json b/composer.json index b494969..2480434 100644 --- a/composer.json +++ b/composer.json @@ -19,14 +19,15 @@ "require": { "php": "~8.2.0", "ext-json": "*", - "ingenerator/warden-core": "^1.2", - "ingenerator/warden-validator-symfony": "^1.2", - "ingenerator/warden-persistence-doctrine": "^1.2", - "ingenerator/kohana-view": "^4.4", - "ingenerator/kohana-extras": "^2.0 || ^3.0", + "composer/installers": "^1.9", + "doctrine/annotations": "^1.13", "ingenerator/kohana-core": "^4.7", + "ingenerator/kohana-extras": "^2.0 || ^3.0", + "ingenerator/kohana-view": "^4.4", "ingenerator/tokenista": "^1.4", - "composer/installers": "^1.9", + "ingenerator/warden-core": "^1.2", + "ingenerator/warden-persistence-doctrine": "^1.2", + "ingenerator/warden-validator-symfony": "^1.2", "symfony/mailer": "^6.3 || ^7.0" }, "require-dev": { @@ -53,6 +54,7 @@ }, "config": { "preferred-install": "dist", + "sort-packages": true, "allow-plugins": { "composer/installers": true } diff --git a/phpunit.xml b/phpunit.xml index c6e655a..dd92eba 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -9,6 +9,9 @@ convertDeprecationsToExceptions="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> + + test/integration + test/unit diff --git a/test/integration/SymfonyValidatorAnnotationTest.php b/test/integration/SymfonyValidatorAnnotationTest.php new file mode 100644 index 0000000..20fd919 --- /dev/null +++ b/test/integration/SymfonyValidatorAnnotationTest.php @@ -0,0 +1,25 @@ + + * @licence proprietary + */ + +namespace integration; + +use Ingenerator\KohanaExtras\DependencyFactory\SymfonyValidationFactory; +use Ingenerator\Warden\Core\Interactor\UserRegistrationRequest; +use Ingenerator\Warden\Validator\Symfony\SymfonyValidator; +use PHPUnit\Framework\TestCase; + +class SymfonyValidatorAnnotationTest extends TestCase +{ + public function test_symfony_validator_is_configured_to_read_doctrine_annotations(): void + { + $warden_validator = new SymfonyValidator(SymfonyValidationFactory::buildValidator()); + $registration_req = UserRegistrationRequest::fromArray(['email' => '', 'password' => '12345678']); + $this->assertSame( + ['email' => 'This value should not be blank.'], + $warden_validator->validate($registration_req) + ); + } +} From 90a8d2c2a2f100afefcd4e069daf3546badfa73d Mon Sep 17 00:00:00 2001 From: craig410 Date: Tue, 13 Feb 2024 12:41:14 +0000 Subject: [PATCH 2/4] We have to require kohana-extras >3.1 To ensure the annotation reader is always attached by the validation factory --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2480434..bc4e237 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "composer/installers": "^1.9", "doctrine/annotations": "^1.13", "ingenerator/kohana-core": "^4.7", - "ingenerator/kohana-extras": "^2.0 || ^3.0", + "ingenerator/kohana-extras": "^3.1", "ingenerator/kohana-view": "^4.4", "ingenerator/tokenista": "^1.4", "ingenerator/warden-core": "^1.2", From 821a720406fcae6c161e9e82f023bec0910a760e Mon Sep 17 00:00:00 2001 From: craig410 Date: Tue, 13 Feb 2024 17:21:48 +0000 Subject: [PATCH 3/4] Require warden-core and warden-validator-symfony at ^1.2.1 So we can use the new `mode=strict` annotation on email fields to replace the deprecated `checkMX=true` which was removed in symfony validator v5 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index bc4e237..57c2244 100644 --- a/composer.json +++ b/composer.json @@ -25,9 +25,9 @@ "ingenerator/kohana-extras": "^3.1", "ingenerator/kohana-view": "^4.4", "ingenerator/tokenista": "^1.4", - "ingenerator/warden-core": "^1.2", + "ingenerator/warden-core": "^1.2.1", "ingenerator/warden-persistence-doctrine": "^1.2", - "ingenerator/warden-validator-symfony": "^1.2", + "ingenerator/warden-validator-symfony": "^1.2.1", "symfony/mailer": "^6.3 || ^7.0" }, "require-dev": { From 2a02aee61bd1b3f230604f20e97bafc1d57da7d9 Mon Sep 17 00:00:00 2001 From: craig410 Date: Tue, 13 Feb 2024 18:56:16 +0000 Subject: [PATCH 4/4] Update changelog for 2.2.0 release --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2424b7..629f50e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ### Unreleased +### v2.2.0 (2024-02-13) + +* Update min requirements of kohana-extras to provide a symfony validator factory which explicitly enables a doctrine annotation reader. Additionally require min versions of warden-core and warden-validator-symfony that are compatible with symfony validator > v5 to use the Assert/Email mode=strict option. + ### v2.1.0 (2024-02-08) * Drop support for PHP 8.1