Skip to content

Commit 9d60fbf

Browse files
authored
Merge pull request #39 from nibra/php8
Chore - Require positive tests on PHP 8.0, additionally test PHP 8.1
2 parents 550ed95 + 638a5dc commit 9d60fbf

File tree

4 files changed

+78
-7
lines changed

4 files changed

+78
-7
lines changed

.drone.jsonnet

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ local composer(phpversion, params) = {
2525
local phpunit(phpversion) = {
2626
name: "PHPUnit",
2727
image: "joomlaprojects/docker-images:php" + phpversion,
28-
[if phpversion == "8.0" then "failure"]: "ignore",
28+
[if phpversion == "8.1" then "failure"]: "ignore",
2929
commands: ["vendor/bin/phpunit"]
3030
};
3131

@@ -110,5 +110,6 @@ local pipeline(name, phpversion, params) = {
110110
pipeline("7.2", "7.2", "--prefer-stable"),
111111
pipeline("7.3", "7.3", "--prefer-stable"),
112112
pipeline("7.4", "7.4", "--prefer-stable"),
113-
pipeline("8.0", "8.0", "--ignore-platform-reqs --prefer-stable")
113+
pipeline("8.0", "8.0", "--prefer-stable"),
114+
pipeline("8.1", "8.1", "--prefer-stable")
114115
]

.drone.yml

+30-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ steps:
181181
image: joomlaprojects/docker-images:php8.0
182182
commands:
183183
- php -v
184-
- composer update --ignore-platform-reqs --prefer-stable
184+
- composer update --prefer-stable
185185
volumes:
186186
- name: composer-cache
187187
path: /tmp/composer-cache
@@ -190,6 +190,34 @@ steps:
190190
image: joomlaprojects/docker-images:php8.0
191191
commands:
192192
- vendor/bin/phpunit
193+
194+
volumes:
195+
- name: composer-cache
196+
host:
197+
path: /tmp/composer-cache
198+
199+
---
200+
kind: pipeline
201+
name: PHP 8.1
202+
203+
platform:
204+
os: linux
205+
arch: amd64
206+
207+
steps:
208+
- name: composer
209+
image: joomlaprojects/docker-images:php8.1
210+
commands:
211+
- php -v
212+
- composer update --prefer-stable
213+
volumes:
214+
- name: composer-cache
215+
path: /tmp/composer-cache
216+
217+
- name: PHPUnit
218+
image: joomlaprojects/docker-images:php8.1
219+
commands:
220+
- vendor/bin/phpunit
193221
failure: ignore
194222

195223
volumes:
@@ -199,6 +227,6 @@ volumes:
199227

200228
---
201229
kind: signature
202-
hmac: fe43177b772ed619009c33251a93354217bc6c33b6c34e2a3249a28508511445
230+
hmac: 4af173bc17cfa22a3f0fcef83a9535adb76d5b3727ab33d8d3c4a51f994525a3
203231

204232
...

Tests/InflectorTest.php

+42
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public function testAddRuleException()
109109
{
110110
$this->expectException(\InvalidArgumentException::class);
111111

112+
/** @noinspection PhpParamsInspection */
112113
TestHelper::invoke($this->inflector, 'addRule', new \stdClass, 'singular');
113114
}
114115

@@ -145,6 +146,11 @@ public function testAddCountableRule()
145146
*/
146147
public function testAddWordWithoutPlural()
147148
{
149+
if (!$this->checkInflectorImplementation($this->inflector))
150+
{
151+
$this->markTestSkipped('This test depends on the library\'s implementation');
152+
}
153+
148154
$this->assertSame(
149155
$this->inflector,
150156
$this->inflector->addWord('foo')
@@ -168,6 +174,11 @@ public function testAddWordWithoutPlural()
168174
*/
169175
public function testAddWordWithPlural()
170176
{
177+
if (!$this->checkInflectorImplementation($this->inflector))
178+
{
179+
$this->markTestSkipped('This test depends on the library\'s implementation');
180+
}
181+
171182
$this->assertEquals(
172183
$this->inflector,
173184
$this->inflector->addWord('bar', 'foo')
@@ -193,6 +204,11 @@ public function testAddWordWithPlural()
193204
*/
194205
public function testAddPluraliseRule()
195206
{
207+
if (!$this->checkInflectorImplementation($this->inflector))
208+
{
209+
$this->markTestSkipped('This test depends on the library\'s implementation');
210+
}
211+
196212
$this->assertSame(
197213
$this->inflector->addPluraliseRule(['/^(custom)$/i' => '\1izables']),
198214
$this->inflector,
@@ -213,6 +229,11 @@ public function testAddPluraliseRule()
213229
*/
214230
public function testAddSingulariseRule()
215231
{
232+
if (!$this->checkInflectorImplementation($this->inflector))
233+
{
234+
$this->markTestSkipped('This test depends on the library\'s implementation');
235+
}
236+
216237
$this->assertSame(
217238
$this->inflector->addSingulariseRule(['/^(inflec|contribu)tors$/i' => '\1ta']),
218239
$this->inflector,
@@ -272,6 +293,10 @@ public function testIsCountable(string $input, bool $expected)
272293
*/
273294
public function testIsPlural(string $singular, string $plural)
274295
{
296+
if ($singular === 'bus' && !$this->checkInflectorImplementation($this->inflector)) {
297+
$this->markTestSkipped('"bus/buses" is not known to the new implementation');
298+
}
299+
275300
$this->assertTrue(
276301
$this->inflector->isPlural($plural),
277302
"'$plural' should be reported as plural"
@@ -296,6 +321,11 @@ public function testIsPlural(string $singular, string $plural)
296321
*/
297322
public function testIsSingular(string $singular, string $plural)
298323
{
324+
if ($singular === 'bus' && !$this->checkInflectorImplementation($this->inflector))
325+
{
326+
$this->markTestSkipped('"bus/buses" is not known to the new implementation');
327+
}
328+
299329
$this->assertTrue(
300330
$this->inflector->isSingular($singular),
301331
"'$singular' should be reported as singular"
@@ -361,10 +391,22 @@ public function testToSingular(string $singular, string $plural)
361391
*/
362392
public function testToSingularAlreadySingular()
363393
{
394+
if (!$this->checkInflectorImplementation($this->inflector))
395+
{
396+
$this->markTestSkipped('"bus/buses" is not known to the new implementation');
397+
}
398+
364399
$this->assertSame(
365400
'bus',
366401
$this->inflector->toSingular('bus'),
367402
"'bus' should not be singularised'"
368403
);
369404
}
405+
406+
private function checkInflectorImplementation(DoctrineInflector $inflector): bool
407+
{
408+
$reflectionClass = new \ReflectionClass($inflector);
409+
410+
return $reflectionClass->hasProperty('plural');
411+
}
370412
}

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
"homepage": "https://github.com/joomla-framework/string",
77
"license": "GPL-2.0-or-later",
88
"require": {
9-
"php": "^7.2.5",
9+
"php": "^7.2.5|^8.0",
1010
"symfony/deprecation-contracts": "^2.1"
1111
},
1212
"require-dev": {
13-
"doctrine/inflector": "1.2",
13+
"doctrine/inflector": "^1.2",
1414
"joomla/coding-standards": "^3.0@dev",
15-
"joomla/test": "^2.0",
15+
"joomla/test": "^2.0.1",
1616
"phpunit/phpunit": "^8.5|^9.0"
1717
},
1818
"conflict": {

0 commit comments

Comments
 (0)