From 4815545ea351e8ee0b5057b5a1dd701702dce7e1 Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Fri, 10 Sep 2021 22:38:17 +0200 Subject: [PATCH 1/6] Add php 8.1 to the test workflow --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7b872357c1..d377acc745 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,6 +23,7 @@ jobs: - '7.3' - '7.4' - '8.0' + - '8.1' include: - operating-system: 'windows-latest' php-version: '7.1' From 21fe98d7d75ce04e9a89915e11c8f1dc42fc0898 Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Fri, 10 Sep 2021 23:24:16 +0200 Subject: [PATCH 2/6] Fix php 8.1 deprecations --- .github/workflows/tests.yml | 7 +++++++ src/Faker/Provider/en_ZA/Person.php | 2 +- test/Faker/Provider/DateTimeTest.php | 2 +- test/Faker/Provider/nl_NL/PersonTest.php | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d377acc745..17ead61e96 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -56,10 +56,17 @@ jobs: composer- - name: Download dependencies + if: ${{ '8.1' <> matrix.php-version }} run: | composer update --no-interaction --no-progress --optimize-autoloader ./vendor/bin/simple-phpunit install + - name: Download dependencies for php 8.1 + if: ${{ '8.1' == matrix.php-version }} + run: | + composer update --no-interaction --no-progress --optimize-autoloader + SYMFONY_PHPUNIT_VERSION=9.5.5 ./vendor/bin/simple-phpunit install + - name: Run tests with PHPUnit run: | ./vendor/bin/simple-phpunit diff --git a/src/Faker/Provider/en_ZA/Person.php b/src/Faker/Provider/en_ZA/Person.php index a9acccf19d..df018d1514 100644 --- a/src/Faker/Provider/en_ZA/Person.php +++ b/src/Faker/Provider/en_ZA/Person.php @@ -148,7 +148,7 @@ public function idNumber(\DateTime $birthdate = null, $citizen = true, $gender = } $birthDateString = $birthdate->format('ymd'); - switch (strtolower($gender)) { + switch (strtolower($gender ?: '')) { case static::GENDER_FEMALE: $genderDigit = self::numberBetween(0, 4); diff --git a/test/Faker/Provider/DateTimeTest.php b/test/Faker/Provider/DateTimeTest.php index 83d0900a1e..86fb27e433 100644 --- a/test/Faker/Provider/DateTimeTest.php +++ b/test/Faker/Provider/DateTimeTest.php @@ -201,7 +201,7 @@ public function providerDateTimeBetween() { return [ ['-1 year', false], - ['-1 year', null], + ['-1 year', ''], ['-1 day', '-1 hour'], ['-1 day', 'now'], ]; diff --git a/test/Faker/Provider/nl_NL/PersonTest.php b/test/Faker/Provider/nl_NL/PersonTest.php index c53704527b..06ebe7bad9 100644 --- a/test/Faker/Provider/nl_NL/PersonTest.php +++ b/test/Faker/Provider/nl_NL/PersonTest.php @@ -18,7 +18,7 @@ public function testGenerateValidIdNumber() $sum = -1 * $idNumber % 10; for ($multiplier = 2; $idNumber > 0; ++$multiplier) { - $val = ($idNumber /= 10) % 10; + $val = (int) ($idNumber /= 10) % 10; $sum += $multiplier * $val; } self::assertTrue($sum != 0 && $sum % 11 == 0); From 44cdbccdad51f1c55fc66db37626601f02247498 Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Fri, 10 Sep 2021 23:27:06 +0200 Subject: [PATCH 3/6] Fix php 8.1 deprecations --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 17ead61e96..447fc91601 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -56,13 +56,13 @@ jobs: composer- - name: Download dependencies - if: ${{ '8.1' <> matrix.php-version }} + if: ${{ '8.1' > matrix.php-version }} run: | composer update --no-interaction --no-progress --optimize-autoloader ./vendor/bin/simple-phpunit install - name: Download dependencies for php 8.1 - if: ${{ '8.1' == matrix.php-version }} + if: ${{ '8.1' <= matrix.php-version }} run: | composer update --no-interaction --no-progress --optimize-autoloader SYMFONY_PHPUNIT_VERSION=9.5.5 ./vendor/bin/simple-phpunit install From ad211ebb1bc868e86a947192859c8310a59797cc Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Fri, 10 Sep 2021 23:30:21 +0200 Subject: [PATCH 4/6] Fix php 8.1 deprecations --- .github/workflows/tests.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 447fc91601..99a12606b3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -56,17 +56,12 @@ jobs: composer- - name: Download dependencies - if: ${{ '8.1' > matrix.php-version }} - run: | - composer update --no-interaction --no-progress --optimize-autoloader - ./vendor/bin/simple-phpunit install + run: composer update --no-interaction --no-progress --optimize-autoloader - - name: Download dependencies for php 8.1 - if: ${{ '8.1' <= matrix.php-version }} - run: | - composer update --no-interaction --no-progress --optimize-autoloader - SYMFONY_PHPUNIT_VERSION=9.5.5 ./vendor/bin/simple-phpunit install + - name: Run tests + if: ${{ '8.1' != matrix.php-version }} + run: ./vendor/bin/simple-phpunit - - name: Run tests with PHPUnit - run: | - ./vendor/bin/simple-phpunit + - name: Run tests for php 8.1 + if: ${{ '8.1' == matrix.php-version }} + run: SYMFONY_PHPUNIT_VERSION=9.5.5 ./vendor/bin/simple-phpunit From 5f5d893907b50e119f663ba50a4bce2d7e0ce4e8 Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Sat, 11 Sep 2021 00:07:32 +0200 Subject: [PATCH 5/6] Change phpunit version constraint for php 8.1 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 99a12606b3..3f94e80de2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -64,4 +64,4 @@ jobs: - name: Run tests for php 8.1 if: ${{ '8.1' == matrix.php-version }} - run: SYMFONY_PHPUNIT_VERSION=9.5.5 ./vendor/bin/simple-phpunit + run: SYMFONY_PHPUNIT_VERSION=9.5 ./vendor/bin/simple-phpunit From 32258dab64a9522b82ac02d591a15f55c9491a91 Mon Sep 17 00:00:00 2001 From: Chris Doehring Date: Mon, 13 Sep 2021 22:16:25 +0200 Subject: [PATCH 6/6] Fix DateTime test --- test/Faker/Provider/DateTimeTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Faker/Provider/DateTimeTest.php b/test/Faker/Provider/DateTimeTest.php index 86fb27e433..86e076b9ca 100644 --- a/test/Faker/Provider/DateTimeTest.php +++ b/test/Faker/Provider/DateTimeTest.php @@ -193,7 +193,7 @@ public function testDateTimeBetween($start, $end) $date = DateTimeProvider::dateTimeBetween($start, $end); self::assertInstanceOf('\DateTime', $date); self::assertGreaterThanOrEqual(new \DateTime($start), $date); - self::assertLessThanOrEqual(new \DateTime($end), $date); + self::assertLessThanOrEqual(new \DateTime($end ?: 'now'), $date); self::assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone()); } @@ -201,7 +201,7 @@ public function providerDateTimeBetween() { return [ ['-1 year', false], - ['-1 year', ''], + ['-1 year', null], ['-1 day', '-1 hour'], ['-1 day', 'now'], ];