Skip to content

Commit 0b9863c

Browse files
authored
Make test data providers in multiple files static (#48)
1 parent 55ddbe0 commit 0b9863c

File tree

4 files changed

+160
-160
lines changed

4 files changed

+160
-160
lines changed

tests/EmailTest.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,23 @@ public function testGetGravatarUrlWithEmptyEmails(): void
9999
is(null, Email::getGravatarUrl(''));
100100
}
101101

102-
public function provideCheckCases(): iterable
102+
public function testRandomEmail(): void
103+
{
104+
isTrue((bool)Email::check(Email::random()));
105+
isTrue(Email::isValid(Email::random()));
106+
107+
isNotSame(Email::random(), Email::random());
108+
isNotSame(Email::random(), Email::random());
109+
isNotSame(Email::random(), Email::random());
110+
}
111+
112+
public function testCheckDns(): void
113+
{
114+
isFalse(Email::checkDns('123'));
115+
isTrue(Email::checkDns('[email protected]'));
116+
}
117+
118+
public static function provideCheckCases(): iterable
103119
{
104120
return [
105121
[
@@ -128,7 +144,7 @@ public function provideCheckCases(): iterable
128144
];
129145
}
130146

131-
public function provideGetDomainsCases(): iterable
147+
public static function provideGetDomainsCases(): iterable
132148
{
133149
return [
134150
[
@@ -166,7 +182,7 @@ public function provideGetDomainsCases(): iterable
166182
];
167183
}
168184

169-
public function provideGetDomainsInAlphabeticalOrderCases(): iterable
185+
public static function provideGetDomainsInAlphabeticalOrderCases(): iterable
170186
{
171187
return [
172188
[
@@ -199,12 +215,12 @@ public function provideGetDomainsInAlphabeticalOrderCases(): iterable
199215
];
200216
}
201217

202-
public function getEmptyProvider(): iterable
218+
public static function getEmptyProvider(): iterable
203219
{
204220
return [[[]], [false], [''], [0]];
205221
}
206222

207-
public function provideGetGravatarUrlCases(): iterable
223+
public static function provideGetGravatarUrlCases(): iterable
208224
{
209225
return [
210226
0 => [
@@ -251,20 +267,4 @@ public function provideGetGravatarUrlCases(): iterable
251267
],
252268
];
253269
}
254-
255-
public function testRandomEmail(): void
256-
{
257-
isTrue((bool)Email::check(Email::random()));
258-
isTrue(Email::isValid(Email::random()));
259-
260-
isNotSame(Email::random(), Email::random());
261-
isNotSame(Email::random(), Email::random());
262-
isNotSame(Email::random(), Email::random());
263-
}
264-
265-
public function testCheckDns(): void
266-
{
267-
isFalse(Email::checkDns('123'));
268-
isTrue(Email::checkDns('[email protected]'));
269-
}
270270
}

tests/EnvTest.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,6 @@
2424
*/
2525
class EnvTest extends PHPUnit
2626
{
27-
public function provideConvertOptionsCases(): iterable
28-
{
29-
return [
30-
['NULL', Env::VAR_NULL, null],
31-
['null', Env::VAR_NULL, null],
32-
33-
['false', Env::VAR_BOOL, false],
34-
['FALSE', Env::VAR_BOOL, false],
35-
['0', Env::VAR_BOOL, false],
36-
['true', Env::VAR_BOOL, true],
37-
['True', Env::VAR_BOOL, true],
38-
['1', Env::VAR_BOOL, true],
39-
40-
['42', Env::VAR_INT, 42],
41-
['FALSE', Env::VAR_INT, 0],
42-
43-
['42.42', Env::VAR_FLOAT, 42.42],
44-
['42', Env::VAR_FLOAT, 42.0],
45-
['FALSE', Env::VAR_FLOAT, 0.],
46-
47-
['"hello"', Env::VAR_STRING, 'hello'],
48-
["'hello'", Env::VAR_STRING, 'hello'],
49-
50-
['"hello"', 0, '"hello"'],
51-
["'hello'", 0, "'hello'"],
52-
];
53-
}
54-
5527
/**
5628
* @dataProvider provideConvertOptionsCases
5729
* @param mixed $value
@@ -141,4 +113,32 @@ public function testIsExists(): void
141113
isTrue(Env::isExists('FOO_EMPTY_2'));
142114
isFalse(Env::isExists('FOO_QWERTY_2'));
143115
}
116+
117+
public static function provideConvertOptionsCases(): iterable
118+
{
119+
return [
120+
['NULL', Env::VAR_NULL, null],
121+
['null', Env::VAR_NULL, null],
122+
123+
['false', Env::VAR_BOOL, false],
124+
['FALSE', Env::VAR_BOOL, false],
125+
['0', Env::VAR_BOOL, false],
126+
['true', Env::VAR_BOOL, true],
127+
['True', Env::VAR_BOOL, true],
128+
['1', Env::VAR_BOOL, true],
129+
130+
['42', Env::VAR_INT, 42],
131+
['FALSE', Env::VAR_INT, 0],
132+
133+
['42.42', Env::VAR_FLOAT, 42.42],
134+
['42', Env::VAR_FLOAT, 42.0],
135+
['FALSE', Env::VAR_FLOAT, 0.],
136+
137+
['"hello"', Env::VAR_STRING, 'hello'],
138+
["'hello'", Env::VAR_STRING, 'hello'],
139+
140+
['"hello"', 0, '"hello"'],
141+
["'hello'", 0, "'hello'"],
142+
];
143+
}
144144
}

tests/FilterTest.php

Lines changed: 109 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,6 @@ public function testInt($exepted, $actual): void
3232
isSame($exepted, Filter::_($actual, 'int'));
3333
}
3434

35-
public function provideIntCases(): iterable
36-
{
37-
return [
38-
[0, null],
39-
[0, false],
40-
[0, ''],
41-
[0, 0],
42-
[1, 1],
43-
[1, '1'],
44-
[1, '01'],
45-
[-1, '-01'],
46-
[-15, ' - 1 5 '],
47-
[-17, ' - 1 asd 7 '],
48-
[-1, ' - 1 . 0 '],
49-
[-1, ' - 1 , 5 '],
50-
[-1, ' - 1 - 0 '],
51-
[3, ' + 3'],
52-
[-4, ' - 4'],
53-
[-5, ' +- 5'],
54-
[6, ' -+ 6'],
55-
];
56-
}
57-
5835
/**
5936
* @dataProvider provideFloatCases
6037
* @param mixed $excepted
@@ -70,38 +47,6 @@ public function testFloat($excepted, $actual, $round = null): void
7047
}
7148
}
7249

73-
public function provideFloatCases(): iterable
74-
{
75-
return [
76-
[0.0, null],
77-
[0.0, false],
78-
[0.0, ''],
79-
[0.0, 'asdasd'],
80-
[0.0, 0],
81-
[1.0, 1],
82-
[123456789.0, 123456789],
83-
[1.0, '1'],
84-
[1.0, '01'],
85-
[-1.0, '-01'],
86-
[-10.0, ' - 1 0 '],
87-
[-1.5, ' - 1,5 '],
88-
[-1.5, ' - 1.5 '],
89-
[-1.512, ' - 1.5123 ', 3],
90-
[-15123.0, ' - 1 asd 5123 ', 3],
91-
[15123.0, ' + 1 asd 5123 ', 3],
92-
93-
[-12.451, 'abc-12,451'],
94-
[-12.452, 'abc-12.452'],
95-
[-12.453, '-abc12.453'],
96-
[-12.454, 'abc-12.454abc'],
97-
[-12.455, 'abc-12. 455'],
98-
[-12.456, 'abc-12. 456 .7'],
99-
[2.6e-19, '26.3e-20', 20],
100-
[2.53E-19, '25.3e-20', 100],
101-
[2.4e-9, '24.3e-10'],
102-
];
103-
}
104-
10550
/**
10651
* @dataProvider provideBoolCases
10752
* @param mixed $excepted
@@ -112,60 +57,6 @@ public function testBool($excepted, $actual): void
11257
isSame($excepted, Filter::_($actual, 'bool'));
11358
}
11459

115-
public function provideBoolCases(): iterable
116-
{
117-
return [
118-
[true, '1'],
119-
[true, ' 1'],
120-
[true, '1 '],
121-
[true, '10'],
122-
[true, '-1'],
123-
[true, true],
124-
[true, 27],
125-
[true, 1.0],
126-
[true, -1],
127-
[true, -1.0],
128-
[true, 10],
129-
[true, 10.0],
130-
[true, 10.0],
131-
[true, 'true'],
132-
[true, 'TRUE'],
133-
[true, 'yes'],
134-
[true, 'YES'],
135-
[true, 'y'],
136-
[true, 'Y'],
137-
[true, 'oui'],
138-
[true, 'vrai'],
139-
[true, 'ДА'],
140-
[true, 'Д'],
141-
[true, '*'],
142-
[true, '+'],
143-
[true, '++'],
144-
[true, '+++'],
145-
[true, '++++'],
146-
[true, '+++++'],
147-
148-
[false, ''],
149-
[false, ' '],
150-
[false, ' 0'],
151-
[false, '0 '],
152-
[false, false],
153-
[false, null],
154-
[false, 0],
155-
[false, '0'],
156-
[false, '0.'],
157-
[false, '0.0'],
158-
[false, '0.00'],
159-
[false, 'false'],
160-
[false, 'no'],
161-
[false, 'n'],
162-
[false, 'non'],
163-
[false, 'faux'],
164-
[false, 'НЕТ'],
165-
[false, '-'],
166-
];
167-
}
168-
16960
public function testDigests(): void
17061
{
17162
$string = " 0 1 a2b 3c!@#$%^&*()-= <>\t";
@@ -362,4 +253,113 @@ public function testJson(): void
362253
isSame($data, (array)Filter::json($obj));
363254
isSame($data, (array)Filter::json($data));
364255
}
256+
257+
public static function provideIntCases(): iterable
258+
{
259+
return [
260+
[0, null],
261+
[0, false],
262+
[0, ''],
263+
[0, 0],
264+
[1, 1],
265+
[1, '1'],
266+
[1, '01'],
267+
[-1, '-01'],
268+
[-15, ' - 1 5 '],
269+
[-17, ' - 1 asd 7 '],
270+
[-1, ' - 1 . 0 '],
271+
[-1, ' - 1 , 5 '],
272+
[-1, ' - 1 - 0 '],
273+
[3, ' + 3'],
274+
[-4, ' - 4'],
275+
[-5, ' +- 5'],
276+
[6, ' -+ 6'],
277+
];
278+
}
279+
280+
public static function provideFloatCases(): iterable
281+
{
282+
return [
283+
[0.0, null],
284+
[0.0, false],
285+
[0.0, ''],
286+
[0.0, 'asdasd'],
287+
[0.0, 0],
288+
[1.0, 1],
289+
[123456789.0, 123456789],
290+
[1.0, '1'],
291+
[1.0, '01'],
292+
[-1.0, '-01'],
293+
[-10.0, ' - 1 0 '],
294+
[-1.5, ' - 1,5 '],
295+
[-1.5, ' - 1.5 '],
296+
[-1.512, ' - 1.5123 ', 3],
297+
[-15123.0, ' - 1 asd 5123 ', 3],
298+
[15123.0, ' + 1 asd 5123 ', 3],
299+
300+
[-12.451, 'abc-12,451'],
301+
[-12.452, 'abc-12.452'],
302+
[-12.453, '-abc12.453'],
303+
[-12.454, 'abc-12.454abc'],
304+
[-12.455, 'abc-12. 455'],
305+
[-12.456, 'abc-12. 456 .7'],
306+
[2.6e-19, '26.3e-20', 20],
307+
[2.53E-19, '25.3e-20', 100],
308+
[2.4e-9, '24.3e-10'],
309+
];
310+
}
311+
312+
public static function provideBoolCases(): iterable
313+
{
314+
return [
315+
[true, '1'],
316+
[true, ' 1'],
317+
[true, '1 '],
318+
[true, '10'],
319+
[true, '-1'],
320+
[true, true],
321+
[true, 27],
322+
[true, 1.0],
323+
[true, -1],
324+
[true, -1.0],
325+
[true, 10],
326+
[true, 10.0],
327+
[true, 10.0],
328+
[true, 'true'],
329+
[true, 'TRUE'],
330+
[true, 'yes'],
331+
[true, 'YES'],
332+
[true, 'y'],
333+
[true, 'Y'],
334+
[true, 'oui'],
335+
[true, 'vrai'],
336+
[true, 'ДА'],
337+
[true, 'Д'],
338+
[true, '*'],
339+
[true, '+'],
340+
[true, '++'],
341+
[true, '+++'],
342+
[true, '++++'],
343+
[true, '+++++'],
344+
345+
[false, ''],
346+
[false, ' '],
347+
[false, ' 0'],
348+
[false, '0 '],
349+
[false, false],
350+
[false, null],
351+
[false, 0],
352+
[false, '0'],
353+
[false, '0.'],
354+
[false, '0.0'],
355+
[false, '0.00'],
356+
[false, 'false'],
357+
[false, 'no'],
358+
[false, 'n'],
359+
[false, 'non'],
360+
[false, 'faux'],
361+
[false, 'НЕТ'],
362+
[false, '-'],
363+
];
364+
}
365365
}

0 commit comments

Comments
 (0)