Skip to content

Commit df45e30

Browse files
committed
fix dataprovider in unit test
1 parent cde9681 commit df45e30

3 files changed

Lines changed: 415 additions & 379 deletions

File tree

Tests/InflectorTest.php

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Doctrine\Common\Inflector\Inflector as DoctrineInflector;
1111
use Joomla\String\Inflector;
1212
use Joomla\Test\TestHelper;
13+
use PHPUnit\Framework\Attributes\DataProvider;
1314
use PHPUnit\Framework\TestCase;
1415

1516
/**
@@ -28,51 +29,55 @@ class InflectorTest extends TestCase
2829
/**
2930
* Method to seed data to testIsCountable.
3031
*
31-
* @return \Generator
32+
* @return array
3233
*/
33-
public function seedIsCountable(): \Generator
34+
public static function seedIsCountableProvider(): array
3435
{
35-
yield ['id', true];
36-
yield ['title', false];
36+
return [
37+
['id', true],
38+
['title', false],
39+
];
3740
}
3841

3942
/**
4043
* Method to seed data to testToPlural.
4144
*
42-
* @return \Generator
45+
* @return array
4346
*
4447
* @since 1.0
4548
*/
46-
public function seedSinglePlural(): \Generator
49+
public static function seedSinglePluralProvider(): array
4750
{
48-
// Regular plurals
49-
yield ['bus', 'buses'];
50-
yield ['notify', 'notifies'];
51-
yield ['click', 'clicks'];
52-
53-
// Almost regular plurals.
54-
yield ['photo', 'photos'];
55-
yield ['zero', 'zeros'];
56-
57-
// Irregular identicals
58-
yield ['salmon', 'salmon'];
59-
60-
// Irregular plurals
61-
yield ['ox', 'oxen'];
62-
yield ['quiz', 'quizzes'];
63-
yield ['status', 'statuses'];
64-
yield ['matrix', 'matrices'];
65-
yield ['index', 'indices'];
66-
yield ['vertex', 'vertices'];
67-
yield ['hive', 'hives'];
68-
69-
// Ablaut plurals
70-
yield ['foot', 'feet'];
71-
yield ['louse', 'lice'];
72-
yield ['man', 'men'];
73-
yield ['mouse', 'mice'];
74-
yield ['tooth', 'teeth'];
75-
yield ['woman', 'women'];
51+
return [
52+
// Regular plurals
53+
['bus', 'buses'],
54+
['notify', 'notifies'],
55+
['click', 'clicks'],
56+
57+
// Almost regular plurals.
58+
['photo', 'photos'],
59+
['zero', 'zeros'],
60+
61+
// Irregular identicals
62+
['salmon', 'salmon'],
63+
64+
// Irregular plurals
65+
['ox', 'oxen'],
66+
['quiz', 'quizzes'],
67+
['status', 'statuses'],
68+
['matrix', 'matrices'],
69+
['index', 'indices'],
70+
['vertex', 'vertices'],
71+
['hive', 'hives'],
72+
73+
// Ablaut plurals
74+
['foot', 'feet'],
75+
['louse', 'lice'],
76+
['man', 'men'],
77+
['mouse', 'mice'],
78+
['tooth', 'teeth'],
79+
['woman', 'women'],
80+
];
7681
}
7782

7883
/**
@@ -269,9 +274,8 @@ public function testGetInstance()
269274
*
270275
* @param string $input A string.
271276
* @param boolean $expected The expected result of the function call.
272-
*
273-
* @dataProvider seedIsCountable
274277
*/
278+
#[DataProvider('seedIsCountableProvider')]
275279
public function testIsCountable(string $input, bool $expected)
276280
{
277281
$this->assertEquals(
@@ -285,9 +289,8 @@ public function testIsCountable(string $input, bool $expected)
285289
*
286290
* @param string $singular The singular form of a word.
287291
* @param string $plural The plural form of a word.
288-
*
289-
* @dataProvider seedSinglePlural
290292
*/
293+
#[DataProvider('seedSinglePluralProvider')]
291294
public function testIsPlural(string $singular, string $plural)
292295
{
293296
if ($singular === 'bus' && !$this->checkInflectorImplementation($this->inflector)) {
@@ -312,9 +315,8 @@ public function testIsPlural(string $singular, string $plural)
312315
*
313316
* @param string $singular The singular form of a word.
314317
* @param string $plural The plural form of a word.
315-
*
316-
* @dataProvider seedSinglePlural
317318
*/
319+
#[DataProvider('seedSinglePluralProvider')]
318320
public function testIsSingular(string $singular, string $plural)
319321
{
320322
if ($singular === 'bus' && !$this->checkInflectorImplementation($this->inflector)) {
@@ -339,9 +341,8 @@ public function testIsSingular(string $singular, string $plural)
339341
*
340342
* @param string $singular The singular form of a word.
341343
* @param string $plural The plural form of a word.
342-
*
343-
* @dataProvider seedSinglePlural
344344
*/
345+
#[DataProvider('seedSinglePluralProvider')]
345346
public function testToPlural(string $singular, string $plural)
346347
{
347348
$this->assertSame(
@@ -368,9 +369,8 @@ public function testToPluralAlreadyPlural()
368369
*
369370
* @param string $singular The singular form of a word.
370371
* @param string $plural The plural form of a word.
371-
*
372-
* @dataProvider seedSinglePlural
373372
*/
373+
#[DataProvider('seedSinglePluralProvider')]
374374
public function testToSingular(string $singular, string $plural)
375375
{
376376
$this->assertSame(

0 commit comments

Comments
 (0)