Skip to content

Commit 2e09dff

Browse files
committed
Upgrade to PHPUnit 8
1 parent a1a8a6c commit 2e09dff

File tree

6 files changed

+342
-438
lines changed

6 files changed

+342
-438
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ vendor/
22
composer.phar
33
composer.lock
44
phpunit.xml
5+
.phpunit.result.cache

Tests/InflectorTest.php

+39-49
Original file line numberDiff line numberDiff line change
@@ -20,65 +20,58 @@
2020
class InflectorTest extends TestCase
2121
{
2222
/**
23-
* @var Inflector
24-
* @since 1.0
23+
* @var Inflector
2524
*/
2625
protected $inflector;
2726

2827
/**
2928
* Method to seed data to testIsCountable.
3029
*
31-
* @return array
32-
*
33-
* @since 1.0
30+
* @return \Generator
3431
*/
35-
public function seedIsCountable()
32+
public function seedIsCountable(): \Generator
3633
{
37-
return array(
38-
array('id', true),
39-
array('title', false),
40-
);
34+
yield ['id', true];
35+
yield ['title', false];
4136
}
4237

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

8477
/**
@@ -87,10 +80,8 @@ public function seedSinglePlural()
8780
* This method is called before a test is executed.
8881
*
8982
* @return void
90-
*
91-
* @since 1.0
9283
*/
93-
protected function setUp()
84+
protected function setUp(): void
9485
{
9586
parent::setUp();
9687

@@ -103,10 +94,8 @@ protected function setUp()
10394
* This method is called after a test is executed.
10495
*
10596
* @return void
106-
*
107-
* @since __DEPLOY_VERSION__
10897
*/
109-
protected function tearDown()
98+
protected function tearDown(): void
11099
{
111100
DoctrineInflector::reset();
112101

@@ -119,11 +108,12 @@ protected function tearDown()
119108
* @return void
120109
*
121110
* @covers Joomla\String\Inflector::addRule
122-
* @expectedException InvalidArgumentException
123111
* @since 1.0
124112
*/
125113
public function testAddRuleException()
126114
{
115+
$this->expectException(\InvalidArgumentException::class);
116+
127117
TestHelper::invoke($this->inflector, 'addRule', new \stdClass, 'singular');
128118
}
129119

Tests/NormaliseTest.php

+74-90
Original file line numberDiff line numberDiff line change
@@ -19,163 +19,147 @@ class NormaliseTest extends TestCase
1919
/**
2020
* Method to seed data to testFromCamelCase.
2121
*
22-
* @return array
22+
* @return \Generator
2323
*
2424
* @since 1.0
2525
*/
26-
public function seedTestFromCamelCase()
26+
public function seedTestFromCamelCase(): \Generator
2727
{
28-
return array(
29-
// Note: string, expected
30-
array('FooBarABCDef', array('Foo', 'Bar', 'ABC', 'Def')),
31-
array('JFooBar', array('J', 'Foo', 'Bar')),
32-
array('J001FooBar002', array('J001', 'Foo', 'Bar002')),
33-
array('abcDef', array('abc', 'Def')),
34-
array('abc_defGhi_Jkl', array('abc_def', 'Ghi_Jkl')),
35-
array('ThisIsA_NASAAstronaut', array('This', 'Is', 'A_NASA', 'Astronaut')),
36-
array('JohnFitzgerald_Kennedy', array('John', 'Fitzgerald_Kennedy')),
37-
);
28+
// Note: string, expected
29+
yield ['FooBarABCDef', ['Foo', 'Bar', 'ABC', 'Def']];
30+
yield ['JFooBar', ['J', 'Foo', 'Bar']];
31+
yield ['J001FooBar002', ['J001', 'Foo', 'Bar002']];
32+
yield ['abcDef', ['abc', 'Def']];
33+
yield ['abc_defGhi_Jkl', ['abc_def', 'Ghi_Jkl']];
34+
yield ['ThisIsA_NASAAstronaut', ['This', 'Is', 'A_NASA', 'Astronaut']];
35+
yield ['JohnFitzgerald_Kennedy', ['John', 'Fitzgerald_Kennedy']];
3836
}
3937

4038
/**
4139
* Method to seed data to testFromCamelCase.
4240
*
43-
* @return array
41+
* @return \Generator
4442
*
4543
* @since 1.0
4644
*/
47-
public function seedTestFromCamelCase_nongrouped()
45+
public function seedTestFromCamelCase_nongrouped(): \Generator
4846
{
49-
return array(
50-
array('Foo Bar', 'FooBar'),
51-
array('foo Bar', 'fooBar'),
52-
array('Foobar', 'Foobar'),
53-
array('foobar', 'foobar')
54-
);
47+
yield ['Foo Bar', 'FooBar'];
48+
yield ['foo Bar', 'fooBar'];
49+
yield ['Foobar', 'Foobar'];
50+
yield ['foobar', 'foobar'];
5551
}
5652

5753
/**
5854
* Method to seed data to testToCamelCase.
5955
*
60-
* @return array
56+
* @return \Generator
6157
*
6258
* @since 1.0
6359
*/
64-
public function seedTestToCamelCase()
60+
public function seedTestToCamelCase(): \Generator
6561
{
66-
return array(
67-
array('FooBar', 'Foo Bar'),
68-
array('FooBar', 'Foo-Bar'),
69-
array('FooBar', 'Foo_Bar'),
70-
array('FooBar', 'foo bar'),
71-
array('FooBar', 'foo-bar'),
72-
array('FooBar', 'foo_bar'),
73-
);
62+
yield ['FooBar', 'Foo Bar'];
63+
yield ['FooBar', 'Foo-Bar'];
64+
yield ['FooBar', 'Foo_Bar'];
65+
yield ['FooBar', 'foo bar'];
66+
yield ['FooBar', 'foo-bar'];
67+
yield ['FooBar', 'foo_bar'];
7468
}
7569

7670
/**
7771
* Method to seed data to testToDashSeparated.
7872
*
79-
* @return array
73+
* @return \Generator
8074
*
8175
* @since 1.0
8276
*/
83-
public function seedTestToDashSeparated()
77+
public function seedTestToDashSeparated(): \Generator
8478
{
85-
return array(
86-
array('Foo-Bar', 'Foo Bar'),
87-
array('Foo-Bar', 'Foo-Bar'),
88-
array('Foo-Bar', 'Foo_Bar'),
89-
array('foo-bar', 'foo bar'),
90-
array('foo-bar', 'foo-bar'),
91-
array('foo-bar', 'foo_bar'),
92-
array('foo-bar', 'foo bar'),
93-
array('foo-bar', 'foo---bar'),
94-
array('foo-bar', 'foo___bar'),
95-
);
79+
yield ['Foo-Bar', 'Foo Bar'];
80+
yield ['Foo-Bar', 'Foo-Bar'];
81+
yield ['Foo-Bar', 'Foo_Bar'];
82+
yield ['foo-bar', 'foo bar'];
83+
yield ['foo-bar', 'foo-bar'];
84+
yield ['foo-bar', 'foo_bar'];
85+
yield ['foo-bar', 'foo bar'];
86+
yield ['foo-bar', 'foo---bar'];
87+
yield ['foo-bar', 'foo___bar'];
9688
}
9789

9890
/**
9991
* Method to seed data to testToSpaceSeparated.
10092
*
101-
* @return array
93+
* @return \Generator
10294
*
10395
* @since 1.0
10496
*/
105-
public function seedTestToSpaceSeparated()
97+
public function seedTestToSpaceSeparated(): \Generator
10698
{
107-
return array(
108-
array('Foo Bar', 'Foo Bar'),
109-
array('Foo Bar', 'Foo-Bar'),
110-
array('Foo Bar', 'Foo_Bar'),
111-
array('foo bar', 'foo bar'),
112-
array('foo bar', 'foo-bar'),
113-
array('foo bar', 'foo_bar'),
114-
array('foo bar', 'foo bar'),
115-
array('foo bar', 'foo---bar'),
116-
array('foo bar', 'foo___bar'),
117-
);
99+
yield ['Foo Bar', 'Foo Bar'];
100+
yield ['Foo Bar', 'Foo-Bar'];
101+
yield ['Foo Bar', 'Foo_Bar'];
102+
yield ['foo bar', 'foo bar'];
103+
yield ['foo bar', 'foo-bar'];
104+
yield ['foo bar', 'foo_bar'];
105+
yield ['foo bar', 'foo bar'];
106+
yield ['foo bar', 'foo---bar'];
107+
yield ['foo bar', 'foo___bar'];
118108
}
119109

120110
/**
121111
* Method to seed data to testToUnderscoreSeparated.
122112
*
123-
* @return array
113+
* @return \Generator
124114
*
125115
* @since 1.0
126116
*/
127-
public function seedTestToUnderscoreSeparated()
117+
public function seedTestToUnderscoreSeparated(): \Generator
128118
{
129-
return array(
130-
array('Foo_Bar', 'Foo Bar'),
131-
array('Foo_Bar', 'Foo-Bar'),
132-
array('Foo_Bar', 'Foo_Bar'),
133-
array('foo_bar', 'foo bar'),
134-
array('foo_bar', 'foo-bar'),
135-
array('foo_bar', 'foo_bar'),
136-
array('foo_bar', 'foo bar'),
137-
array('foo_bar', 'foo---bar'),
138-
array('foo_bar', 'foo___bar'),
139-
);
119+
yield ['Foo_Bar', 'Foo Bar'];
120+
yield ['Foo_Bar', 'Foo-Bar'];
121+
yield ['Foo_Bar', 'Foo_Bar'];
122+
yield ['foo_bar', 'foo bar'];
123+
yield ['foo_bar', 'foo-bar'];
124+
yield ['foo_bar', 'foo_bar'];
125+
yield ['foo_bar', 'foo bar'];
126+
yield ['foo_bar', 'foo---bar'];
127+
yield ['foo_bar', 'foo___bar'];
140128
}
141129

142130
/**
143131
* Method to seed data to testToVariable.
144132
*
145-
* @return array
133+
* @return \Generator
146134
*
147135
* @since 1.0
148136
*/
149-
public function seedTestToVariable()
137+
public function seedTestToVariable(): \Generator
150138
{
151-
return array(
152-
array('myFooBar', 'My Foo Bar'),
153-
array('myFooBar', 'My Foo-Bar'),
154-
array('myFooBar', 'My Foo_Bar'),
155-
array('myFooBar', 'my foo bar'),
156-
array('myFooBar', 'my foo-bar'),
157-
array('myFooBar', 'my foo_bar'),
158-
array('abc3def4', '1abc3def4'),
159-
);
139+
yield ['myFooBar', 'My Foo Bar'];
140+
yield ['myFooBar', 'My Foo-Bar'];
141+
yield ['myFooBar', 'My Foo_Bar'];
142+
yield ['myFooBar', 'my foo bar'];
143+
yield ['myFooBar', 'my foo-bar'];
144+
yield ['myFooBar', 'my foo_bar'];
145+
yield ['abc3def4', '1abc3def4'];
160146
}
161147

162148
/**
163149
* Method to seed data to testToKey.
164150
*
165-
* @return array
151+
* @return \Generator
166152
*
167153
* @since 1.0
168154
*/
169-
public function seedTestToKey()
155+
public function seedTestToKey(): \Generator
170156
{
171-
return array(
172-
array('foo_bar', 'Foo Bar'),
173-
array('foo_bar', 'Foo-Bar'),
174-
array('foo_bar', 'Foo_Bar'),
175-
array('foo_bar', 'foo bar'),
176-
array('foo_bar', 'foo-bar'),
177-
array('foo_bar', 'foo_bar'),
178-
);
157+
yield ['foo_bar', 'Foo Bar'];
158+
yield ['foo_bar', 'Foo-Bar'];
159+
yield ['foo_bar', 'Foo_Bar'];
160+
yield ['foo_bar', 'foo bar'];
161+
yield ['foo_bar', 'foo-bar'];
162+
yield ['foo_bar', 'foo_bar'];
179163
}
180164

181165
/**

0 commit comments

Comments
 (0)