Skip to content

Commit

Permalink
Merge pull request #25 from ingenerator/test-validation-annotations
Browse files Browse the repository at this point in the history
Ensure validation annotations are being read and validated
  • Loading branch information
craig410 authored Feb 14, 2024
2 parents 0250a2b + 2a02aee commit 4618793
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 8 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "^3.1",
"ingenerator/kohana-view": "^4.4",
"ingenerator/tokenista": "^1.4",
"composer/installers": "^1.9",
"ingenerator/warden-core": "^1.2.1",
"ingenerator/warden-persistence-doctrine": "^1.2",
"ingenerator/warden-validator-symfony": "^1.2.1",
"symfony/mailer": "^6.3 || ^7.0"
},
"require-dev": {
Expand All @@ -53,6 +54,7 @@
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"allow-plugins": {
"composer/installers": true
}
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
convertDeprecationsToExceptions="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<testsuites>
<testsuite name="Integration">
<directory>test/integration</directory>
</testsuite>
<testsuite name="Unit">
<directory>test/unit</directory>
</testsuite>
Expand Down
25 changes: 25 additions & 0 deletions test/integration/SymfonyValidatorAnnotationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* @author Craig Gosman <[email protected]>
* @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)
);
}
}

0 comments on commit 4618793

Please sign in to comment.