From 5780cd5bbcd1e77546ff623d4a3b295fcfefca7f Mon Sep 17 00:00:00 2001 From: Niels Braczek Date: Thu, 23 Sep 2021 13:23:27 +0200 Subject: [PATCH 1/6] Chore - Require positive tests on PHP 8.0, additionally test PHP 8.1 --- .drone.jsonnet | 5 +++-- .drone.yml | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index ab2b93f7..00a89d9d 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -25,7 +25,7 @@ local composer(phpversion, params) = { local phpunit(phpversion) = { name: "PHPUnit", image: "joomlaprojects/docker-images:php" + phpversion, - [if phpversion == "8.0" then "failure"]: "ignore", + [if phpversion == "8.1" then "failure"]: "ignore", commands: ["vendor/bin/phpunit"] }; @@ -110,5 +110,6 @@ local pipeline(name, phpversion, params) = { pipeline("7.2", "7.2", "--prefer-stable"), pipeline("7.3", "7.3", "--prefer-stable"), pipeline("7.4", "7.4", "--prefer-stable"), - pipeline("8.0", "8.0", "--ignore-platform-reqs --prefer-stable") + pipeline("8.0", "8.0", "--prefer-stable"), + pipeline("8.1", "8.1", "--prefer-stable") ] diff --git a/.drone.yml b/.drone.yml index baf1e9d0..dce1bba4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -181,7 +181,7 @@ steps: image: joomlaprojects/docker-images:php8.0 commands: - php -v - - composer update --ignore-platform-reqs --prefer-stable + - composer update --prefer-stable volumes: - name: composer-cache path: /tmp/composer-cache @@ -190,6 +190,34 @@ steps: image: joomlaprojects/docker-images:php8.0 commands: - vendor/bin/phpunit + +volumes: +- name: composer-cache + host: + path: /tmp/composer-cache + +--- +kind: pipeline +name: PHP 8.1 + +platform: + os: linux + arch: amd64 + +steps: +- name: composer + image: joomlaprojects/docker-images:php8.1 + commands: + - php -v + - composer update --prefer-stable + volumes: + - name: composer-cache + path: /tmp/composer-cache + +- name: PHPUnit + image: joomlaprojects/docker-images:php8.1 + commands: + - vendor/bin/phpunit failure: ignore volumes: @@ -199,6 +227,6 @@ volumes: --- kind: signature -hmac: fe43177b772ed619009c33251a93354217bc6c33b6c34e2a3249a28508511445 +hmac: 4af173bc17cfa22a3f0fcef83a9535adb76d5b3727ab33d8d3c4a51f994525a3 ... From 4ed5f1bd6ed3aef92317b1a5e4949b5778413890 Mon Sep 17 00:00:00 2001 From: Niels Braczek Date: Thu, 23 Sep 2021 13:34:08 +0200 Subject: [PATCH 2/6] Chore - Allow PHP 8.0+ --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 961171a7..3a2c4451 100644 --- a/composer.json +++ b/composer.json @@ -6,11 +6,11 @@ "homepage": "https://github.com/joomla-framework/string", "license": "GPL-2.0-or-later", "require": { - "php": "^7.2.5", + "php": "^7.2.5|^8.0", "symfony/deprecation-contracts": "^2.1" }, "require-dev": { - "doctrine/inflector": "1.2", + "doctrine/inflector": "^1.2", "joomla/coding-standards": "^3.0@dev", "joomla/test": "^2.0", "phpunit/phpunit": "^8.5|^9.0" From 9782bab6f318eb170207e3498d11b089465aa595 Mon Sep 17 00:00:00 2001 From: Niels Braczek Date: Thu, 23 Sep 2021 15:07:20 +0200 Subject: [PATCH 3/6] Chore - Update TestHelper --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3a2c4451..fa625bfc 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "require-dev": { "doctrine/inflector": "^1.2", "joomla/coding-standards": "^3.0@dev", - "joomla/test": "^2.0", + "joomla/test": "^2.0.1", "phpunit/phpunit": "^8.5|^9.0" }, "conflict": { From fe3afc464553fac47f3d2a1e45b53b46bf096d72 Mon Sep 17 00:00:00 2001 From: Niels Braczek Date: Thu, 23 Sep 2021 15:49:54 +0200 Subject: [PATCH 4/6] Chore - Stick with Doctrine Inflector 1.2 Tests are relying on implementation details of the library --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fa625bfc..e5775f36 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "symfony/deprecation-contracts": "^2.1" }, "require-dev": { - "doctrine/inflector": "^1.2", + "doctrine/inflector": "1.2", "joomla/coding-standards": "^3.0@dev", "joomla/test": "^2.0.1", "phpunit/phpunit": "^8.5|^9.0" From 500eb422cfeacc8a23ee0ff803f4fa11e3cb4ee0 Mon Sep 17 00:00:00 2001 From: Niels Braczek Date: Thu, 23 Sep 2021 18:36:16 +0200 Subject: [PATCH 5/6] Tests - Skip tests if they don't match the expected implementation --- Tests/InflectorTest.php | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Tests/InflectorTest.php b/Tests/InflectorTest.php index 9948baf2..c934d10d 100644 --- a/Tests/InflectorTest.php +++ b/Tests/InflectorTest.php @@ -109,6 +109,7 @@ public function testAddRuleException() { $this->expectException(\InvalidArgumentException::class); + /** @noinspection PhpParamsInspection */ TestHelper::invoke($this->inflector, 'addRule', new \stdClass, 'singular'); } @@ -145,6 +146,11 @@ public function testAddCountableRule() */ public function testAddWordWithoutPlural() { + if (!$this->checkInflectorImplementation($this->inflector)) + { + $this->markTestSkipped('This test depends on the library\'s implementation'); + } + $this->assertSame( $this->inflector, $this->inflector->addWord('foo') @@ -168,6 +174,11 @@ public function testAddWordWithoutPlural() */ public function testAddWordWithPlural() { + if (!$this->checkInflectorImplementation($this->inflector)) + { + $this->markTestSkipped('This test depends on the library\'s implementation'); + } + $this->assertEquals( $this->inflector, $this->inflector->addWord('bar', 'foo') @@ -193,6 +204,11 @@ public function testAddWordWithPlural() */ public function testAddPluraliseRule() { + if (!$this->checkInflectorImplementation($this->inflector)) + { + $this->markTestSkipped('This test depends on the library\'s implementation'); + } + $this->assertSame( $this->inflector->addPluraliseRule(['/^(custom)$/i' => '\1izables']), $this->inflector, @@ -213,6 +229,11 @@ public function testAddPluraliseRule() */ public function testAddSingulariseRule() { + if (!$this->checkInflectorImplementation($this->inflector)) + { + $this->markTestSkipped('This test depends on the library\'s implementation'); + } + $this->assertSame( $this->inflector->addSingulariseRule(['/^(inflec|contribu)tors$/i' => '\1ta']), $this->inflector, @@ -272,6 +293,10 @@ public function testIsCountable(string $input, bool $expected) */ public function testIsPlural(string $singular, string $plural) { + if ($singular === 'bus' && !$this->checkInflectorImplementation($this->inflector)) { + $this->markTestSkipped('"bus/buses" is not known to the new implementation'); + } + $this->assertTrue( $this->inflector->isPlural($plural), "'$plural' should be reported as plural" @@ -296,6 +321,11 @@ public function testIsPlural(string $singular, string $plural) */ public function testIsSingular(string $singular, string $plural) { + if ($singular === 'bus' && !$this->checkInflectorImplementation($this->inflector)) + { + $this->markTestSkipped('"bus/buses" is not known to the new implementation'); + } + $this->assertTrue( $this->inflector->isSingular($singular), "'$singular' should be reported as singular" @@ -361,10 +391,22 @@ public function testToSingular(string $singular, string $plural) */ public function testToSingularAlreadySingular() { + if (!$this->checkInflectorImplementation($this->inflector)) + { + $this->markTestSkipped('"bus/buses" is not known to the new implementation'); + } + $this->assertSame( 'bus', $this->inflector->toSingular('bus'), "'bus' should not be singularised'" ); } + + private function checkInflectorImplementation(DoctrineInflector $inflector): bool + { + $reflectionClass = new \ReflectionClass($inflector); + + return $reflectionClass->hasProperty('plural'); + } } From 638a5dcdfd46e99ae0056f6b98dd1f9af8de76b6 Mon Sep 17 00:00:00 2001 From: Niels Braczek Date: Thu, 23 Sep 2021 18:38:27 +0200 Subject: [PATCH 6/6] Chore - allow PHP 8.0 compatible version of Doctrine\Inflector --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e5775f36..fa625bfc 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "symfony/deprecation-contracts": "^2.1" }, "require-dev": { - "doctrine/inflector": "1.2", + "doctrine/inflector": "^1.2", "joomla/coding-standards": "^3.0@dev", "joomla/test": "^2.0.1", "phpunit/phpunit": "^8.5|^9.0"