Skip to content

Commit

Permalink
Merge pull request #98 from wmde/update-validators-dependency
Browse files Browse the repository at this point in the history
Update Dependencies
  • Loading branch information
gbirke authored Jun 18, 2020
2 parents dc71033 + b9c2c0a commit 56149db
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"wmde/email-address": "~1.0",
"wmde/euro": "~1.0",
"wmde/freezable-value-object": "~1.0",
"wmde/fun-validators": "~2.0.0",
"wmde/fundraising-payments": "~1.0.1"
"wmde/fun-validators": "~3.0.0",
"wmde/fundraising-payments": "~1.0.0"
},
"repositories": [
{
Expand Down
6 changes: 6 additions & 0 deletions tests/Data/ValidatorPatterns.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ class ValidatorPatterns {
'LI' => '/^[0-9]{4}$/',
'LU' => '/^[0-9]{4}$/',
];

public const ADDRESS_PATTERNS = [
'firstName' => "/^[A-Za-z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\\s\\-\\.\\']+$/",
'lastName' => "/^[A-Za-z\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff\\s\\-\\.\\']+$/",
'postcode' => '/^.+$/',
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private function newEmptyIbanBlocklist(): IbanBlocklist {
}

private function newAddressValidator(): AddressValidator {
return new AddressValidator( ValidatorPatterns::COUNTRY_POSTCODE );
return new AddressValidator( ValidatorPatterns::COUNTRY_POSTCODE, ValidatorPatterns::ADDRESS_PATTERNS );
}

}
9 changes: 6 additions & 3 deletions tests/Unit/UseCases/UpdateDonor/UpdateDonorValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
class UpdateDonorValidatorTest extends TestCase {

public function testGivenAnonymousDonor_validationFails() {
$validator = new UpdateDonorValidator( new AddressValidator( ValidatorPatterns::COUNTRY_POSTCODE ), new SucceedingEmailValidator() );
$validator = new UpdateDonorValidator(
new AddressValidator( ValidatorPatterns::COUNTRY_POSTCODE, ValidatorPatterns::ADDRESS_PATTERNS ),
new SucceedingEmailValidator()
);
$request = ( new UpdateDonorRequest() )->withType( DonorName::PERSON_ANONYMOUS );

$result = $validator->validateDonorData( $request );
Expand Down Expand Up @@ -58,7 +61,7 @@ public function testGivenFailingDonorValidator_validationFails() {

public function testgivenEmptyDonorRequestValues_validationFails() {
$validator = new UpdateDonorValidator(
new AddressValidator( ValidatorPatterns::COUNTRY_POSTCODE ),
new AddressValidator( ValidatorPatterns::COUNTRY_POSTCODE, ValidatorPatterns::ADDRESS_PATTERNS ),
new EmailValidator( new SucceedingDomainNameValidator() )
);
$result = $validator->validateDonorData( $this->newEmptyUpdateDonorRequest() );
Expand All @@ -76,7 +79,7 @@ public function testgivenEmptyDonorRequestValues_validationFails() {

public function testGivenInvalidCompanyDonor_validationFails() {
$validator = new UpdateDonorValidator(
new AddressValidator( ValidatorPatterns::COUNTRY_POSTCODE ),
new AddressValidator( ValidatorPatterns::COUNTRY_POSTCODE, ValidatorPatterns::ADDRESS_PATTERNS ),
new EmailValidator( new SucceedingDomainNameValidator() )
);
$result = $validator->validateDonorData( $this->newInvalidUpdateCompanyDonorRequest() );
Expand Down

0 comments on commit 56149db

Please sign in to comment.