Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
};

Expand Down Expand Up @@ -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")
]
32 changes: 30 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -199,6 +227,6 @@ volumes:

---
kind: signature
hmac: fe43177b772ed619009c33251a93354217bc6c33b6c34e2a3249a28508511445
hmac: 4af173bc17cfa22a3f0fcef83a9535adb76d5b3727ab33d8d3c4a51f994525a3

...
42 changes: 42 additions & 0 deletions Tests/InflectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public function testAddRuleException()
{
$this->expectException(\InvalidArgumentException::class);

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

Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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');
}
}
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"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",
"joomla/test": "^2.0.1",
"phpunit/phpunit": "^8.5|^9.0"
},
"conflict": {
Expand Down