@@ -19,6 +19,9 @@ final class InflectorPluralizerTest extends TestCase
1919 #[TestWith(['Migration ' , 'Migrations ' , 2 ])]
2020 #[TestWith(['migration ' , 'migrations ' , 2 ])]
2121 #[TestWith(['migration ' , 'migrations ' , [1 , 2 ]])]
22+ #[TestWith(['category ' , 'categories ' , 2 ])]
23+ #[TestWith(['status ' , 'statuses ' , 2 ])]
24+ #[TestWith(['child ' , 'children ' , 2 ])]
2225 public function test_that_pluralizer_pluralizes (string $ value , string $ expected , int |array |Countable $ count ): void
2326 {
2427 $ pluralizer = new InflectorPluralizer ();
@@ -28,10 +31,67 @@ public function test_that_pluralizer_pluralizes(string $value, string $expected,
2831
2932 #[TestWith(['Migrations ' , 'Migration ' ])]
3033 #[TestWith(['migrations ' , 'migration ' ])]
34+ #[TestWith(['categories ' , 'category ' ])]
35+ #[TestWith(['statuses ' , 'status ' ])]
36+ #[TestWith(['children ' , 'child ' ])]
3137 public function test_that_pluralizer_singularizes (string $ value , string $ expected ): void
3238 {
3339 $ pluralizer = new InflectorPluralizer ();
3440
3541 $ this ->assertEquals ($ expected , $ pluralizer ->singularize ($ value ));
3642 }
43+
44+ #[TestWith(['bookAuthors ' , 'bookAuthor ' ])]
45+ #[TestWith(['BookAuthors ' , 'BookAuthor ' ])]
46+ #[TestWith(['book_authors ' , 'book_author ' ])]
47+ #[TestWith(['product_metadata ' , 'product_metadata ' ])]
48+ #[TestWith(['user_book_categories ' , 'user_book_category ' ])]
49+ #[TestWith(['authors ' , 'author ' ])]
50+ #[TestWith(['' , '' ])]
51+ #[TestWith(['BOOK_AUTHORS ' , 'BOOK_AUTHOR ' ])]
52+ #[TestWith(['USER_STATUSES ' , 'USER_STATUS ' ])]
53+ #[TestWith(['BOOK_CATEGORIES ' , 'BOOK_CATEGORY ' ])]
54+ #[TestWith(['parseHTMLElements ' , 'parseHTMLElement ' ])]
55+ #[TestWith(['HTMLElements ' , 'HTMLElement ' ])]
56+ #[TestWith(['getHTTPSResponses ' , 'getHTTPSResponse ' ])]
57+ #[TestWith(['_authors ' , '_author ' ])]
58+ #[TestWith(['authors_ ' , 'author_ ' ])]
59+ #[TestWith(['authors__ ' , 'author__ ' ])]
60+ #[TestWith(['book__authors ' , 'book__author ' ])]
61+ #[TestWith(['_ ' , '_ ' ])]
62+ #[TestWith(['__ ' , '__ ' ])]
63+ #[TestWith(['Multiple Aircraft ' , 'Multiple Aircraft ' ])]
64+ public function test_singularize_last_word (string $ value , string $ expected ): void
65+ {
66+ $ pluralizer = new InflectorPluralizer ();
67+
68+ $ this ->assertEquals ($ expected , $ pluralizer ->singularizeLastWord ($ value ));
69+ }
70+
71+ #[TestWith(['bookAuthor ' , 'bookAuthors ' ])]
72+ #[TestWith(['BookAuthor ' , 'BookAuthors ' ])]
73+ #[TestWith(['book_author ' , 'book_authors ' ])]
74+ #[TestWith(['product_metadata ' , 'product_metadata ' ])]
75+ #[TestWith(['user_book_category ' , 'user_book_categories ' ])]
76+ #[TestWith(['author ' , 'authors ' ])]
77+ #[TestWith(['' , '' ])]
78+ #[TestWith(['BOOK_AUTHOR ' , 'BOOK_AUTHORS ' ])]
79+ #[TestWith(['USER_STATUS ' , 'USER_STATUSES ' ])]
80+ #[TestWith(['BOOK_CATEGORY ' , 'BOOK_CATEGORIES ' ])]
81+ #[TestWith(['parseHTMLElement ' , 'parseHTMLElements ' ])]
82+ #[TestWith(['HTMLElement ' , 'HTMLElements ' ])]
83+ #[TestWith(['getHTTPSResponse ' , 'getHTTPSResponses ' ])]
84+ #[TestWith(['_author ' , '_authors ' ])]
85+ #[TestWith(['author_ ' , 'authors_ ' ])]
86+ #[TestWith(['author__ ' , 'authors__ ' ])]
87+ #[TestWith(['book__author ' , 'book__authors ' ])]
88+ #[TestWith(['_ ' , '_ ' ])]
89+ #[TestWith(['__ ' , '__ ' ])]
90+ #[TestWith(['Multiple Aircraft ' , 'Multiple Aircraft ' ])]
91+ public function test_pluralize_last_word (string $ value , string $ expected ): void
92+ {
93+ $ pluralizer = new InflectorPluralizer ();
94+
95+ $ this ->assertEquals ($ expected , $ pluralizer ->pluralizeLastWord ($ value ));
96+ }
3797}
0 commit comments