Skip to content

Commit 27aa942

Browse files
authored
Merge pull request #4 from wmde/php-7-2
Test against PHP 7.2, too
2 parents a1d9891 + 1cd7f3a commit 27aa942

File tree

6 files changed

+38
-7
lines changed

6 files changed

+38
-7
lines changed
File renamed without changes.

Dockerfile-7.2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM php:7.2-cli
2+
3+
RUN \
4+
apt-get update && \
5+
# for intl
6+
apt-get install -y libicu-dev && \
7+
docker-php-ext-install -j$(nproc) intl

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ test: covers phpunit
1515
cs: phpcs stan
1616

1717
phpunit:
18-
docker-compose run --rm app ./vendor/bin/phpunit
18+
docker-compose run --rm fun-validators-7.1 ./vendor/bin/phpunit
19+
docker-compose run --rm fun-validators-7.2 ./vendor/bin/phpunit
1920

2021
phpcs:
21-
docker-compose run --rm app ./vendor/bin/phpcs
22+
docker-compose run --rm fun-validators-7.1 ./vendor/bin/phpcs
23+
docker-compose run --rm fun-validators-7.2 ./vendor/bin/phpcs
2224

2325
stan:
24-
docker-compose run --rm app ./vendor/bin/phpstan analyse --level=1 --no-progress src/ tests/
26+
docker-compose run --rm fun-validators-7.1 ./vendor/bin/phpstan analyse --level=1 --no-progress src/ tests/
27+
docker-compose run --rm fun-validators-7.2 ./vendor/bin/phpstan analyse --level=1 --no-progress src/ tests/
2528

2629
covers:
27-
docker-compose run --rm app ./vendor/bin/covers-validator
30+
docker-compose run --rm fun-validators-7.1 ./vendor/bin/covers-validator
31+
docker-compose run --rm fun-validators-7.2 ./vendor/bin/covers-validator
2832

2933
composer:
3034
docker run --rm --interactive --tty --volume $(shell pwd):/app -w /app\

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@ To run just the PHPUnit tests run
5656
To run only a subset of PHPUnit tests or otherwise pass flags to PHPUnit, run
5757

5858
docker-compose run --rm app ./vendor/bin/phpunit --filter SomeClassNameOrFilter
59+
60+
If you have failing unit tests but want to run them for all PHP versions
61+
(normally it would bail on the first error) you can do so using
62+
63+
make -i test
64+
65+
In this case do keep in mind that the exit code **can not** be used to assess the run's success.

docker-compose.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
version: '2'
22

33
services:
4-
app:
5-
build: .
4+
fun-validators-7.1:
5+
build:
6+
context: ./
7+
dockerfile: Dockerfile-7.1
8+
image: fun-validators:7.1
69
volumes:
710
- ./:/usr/src/app
811
working_dir: /usr/src/app
12+
13+
fun-validators-7.2:
14+
extends:
15+
service: fun-validators-7.1
16+
build:
17+
context: ./
18+
dockerfile: Dockerfile-7.2
19+
image: fun-validators:7.2

src/Validators/EmailValidator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace WMDE\FunValidators\Validators;
66

7+
use const IDNA_NONTRANSITIONAL_TO_ASCII;
8+
use const INTL_IDNA_VARIANT_UTS46;
79
use WMDE\FunValidators\ConstraintViolation;
810
use WMDE\FunValidators\DomainNameValidator;
911
use WMDE\FunValidators\ValidationResult;
@@ -36,7 +38,7 @@ public function validate( string $emailAddress ): ValidationResult {
3638
return new ValidationResult( new ConstraintViolation( $emailAddress, 'email_address_wrong_format' ) );
3739
}
3840

39-
$normalizedDomain = (string)idn_to_ascii( $domain );
41+
$normalizedDomain = (string)idn_to_ascii( $domain, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46 );
4042

4143
if ( !filter_var( $userName . '@' . $normalizedDomain, FILTER_VALIDATE_EMAIL ) ) {
4244
return new ValidationResult( new ConstraintViolation( $emailAddress, 'email_address_invalid' ) );

0 commit comments

Comments
 (0)