From ade2b3bbfb776f27f0558e26eed43b5d9fe1b392 Mon Sep 17 00:00:00 2001 From: powellblyth Date: Wed, 7 Sep 2022 10:01:28 +0100 Subject: [PATCH] Ensures that Tights, and Shorts and Blouse are single/pluralised properly (#202) * Ensures that Tights, and Shorts are never singularised in English, ensures that Blouses is never singularised to Blice * Add Unit tests for Blouse, Shorts, Tights --- lib/Doctrine/Inflector/Rules/English/Inflectible.php | 3 +++ .../Tests/Inflector/Rules/English/EnglishFunctionalTest.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/Doctrine/Inflector/Rules/English/Inflectible.php b/lib/Doctrine/Inflector/Rules/English/Inflectible.php index 8f0919fc..daee3ca2 100644 --- a/lib/Doctrine/Inflector/Rules/English/Inflectible.php +++ b/lib/Doctrine/Inflector/Rules/English/Inflectible.php @@ -56,6 +56,8 @@ public static function getSingular(): iterable yield new Transformation(new Pattern('(f)eet$'), '\1oot'); yield new Transformation(new Pattern('(n)ews$'), '\1\2ews'); yield new Transformation(new Pattern('eaus$'), 'eau'); + yield new Transformation(new Pattern('^tights$'), 'tights'); + yield new Transformation(new Pattern('^shorts$'), 'shorts'); yield new Transformation(new Pattern('s$'), ''); } @@ -99,6 +101,7 @@ public static function getIrregular(): iterable yield new Substitution(new Word('atlas'), new Word('atlases')); yield new Substitution(new Word('axe'), new Word('axes')); yield new Substitution(new Word('beef'), new Word('beefs')); + yield new Substitution(new Word('blouse'), new Word('blouses')); yield new Substitution(new Word('brother'), new Word('brothers')); yield new Substitution(new Word('cafe'), new Word('cafes')); yield new Substitution(new Word('chateau'), new Word('chateaux')); diff --git a/tests/Doctrine/Tests/Inflector/Rules/English/EnglishFunctionalTest.php b/tests/Doctrine/Tests/Inflector/Rules/English/EnglishFunctionalTest.php index a9593307..17f7ca05 100644 --- a/tests/Doctrine/Tests/Inflector/Rules/English/EnglishFunctionalTest.php +++ b/tests/Doctrine/Tests/Inflector/Rules/English/EnglishFunctionalTest.php @@ -47,6 +47,7 @@ public function dataSampleWords(): array ['baggage', 'baggage'], ['basis', 'bases'], ['bison', 'bison'], + ['blouse', 'blouses'], ['borghese', 'borghese'], ['box', 'boxes'], ['bream', 'bream'], @@ -352,6 +353,7 @@ public function dataSampleWords(): array ['shelf', 'shelves'], ['shoe', 'shoes'], ['shoe', 'shoes'], + ['shorts', 'shorts'], ['siemens', 'siemens'], ['silk', 'silk'], ['sku', 'skus'], @@ -393,6 +395,7 @@ public function dataSampleWords(): array ['testis', 'testes'], ['thesis', 'theses'], ['Thief', 'Thieves'], + ['tights', 'tights'], ['tomato', 'tomatoes'], ['tomato', 'tomatoes'], ['tooth', 'teeth'],