Skip to content

Commit 8c36a04

Browse files
committed
Switch data providers from array to Generator
1 parent 0ec3393 commit 8c36a04

35 files changed

+1650
-1708
lines changed

tests/Rules/AustrianInsuranceNumberTest.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Intervention\Validation\Tests\Rules;
66

7+
use Generator;
78
use Intervention\Validation\Rules\AustrianInsuranceNumber;
89
use PHPUnit\Framework\Attributes\DataProvider;
910
use PHPUnit\Framework\TestCase;
@@ -17,22 +18,20 @@ public function testValidation($result, $value): void
1718
$this->assertEquals($result, $valid);
1819
}
1920

20-
public static function dataProvider(): array
21+
public static function dataProvider(): Generator
2122
{
22-
return [
23-
[true, '8757080475'],
24-
[true, '1230011471'],
25-
[false, '1234567890'],
26-
[false, '0123456789'],
27-
[false, '12345'],
28-
[false, '25bc78'],
29-
[false, '8753080475'],
30-
[false, 'foo'],
31-
[true, '1230 011471'],
32-
[false, '9999999999'],
33-
[false, '9999202501'],
34-
[false, '9999009901'],
35-
[true, '1680250250'],
36-
];
23+
yield [true, '8757080475'];
24+
yield [true, '1230011471'];
25+
yield [false, '1234567890'];
26+
yield [false, '0123456789'];
27+
yield [false, '12345'];
28+
yield [false, '25bc78'];
29+
yield [false, '8753080475'];
30+
yield [false, 'foo'];
31+
yield [true, '1230 011471'];
32+
yield [false, '9999999999'];
33+
yield [false, '9999202501'];
34+
yield [false, '9999009901'];
35+
yield [true, '1680250250'];
3736
}
3837
}

tests/Rules/Base64Test.php

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Intervention\Validation\Tests\Rules;
66

7+
use Generator;
78
use PHPUnit\Framework\Attributes\DataProvider;
89
use Intervention\Validation\Rules\Base64;
910
use PHPUnit\Framework\TestCase;
@@ -17,54 +18,52 @@ public function testValidation($result, $value): void
1718
$this->assertEquals($result, $valid);
1819
}
1920

20-
public static function dataProvider(): array
21+
public static function dataProvider(): Generator
2122
{
22-
return [
23-
[
24-
true,
25-
'Zm9v'
26-
],
27-
[
28-
true,
29-
'YmFy'
30-
],
31-
[
32-
true,
33-
'VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZy4='
34-
],
35-
[
36-
true,
37-
'bGFuZ3VhZ2U6IHBocAoKZGlzdDogJ3RydXN0eScKCnBocDoKICAtICc3LjInCiAgLSAnNy4zJw' .
23+
yield [
24+
true,
25+
'Zm9v'
26+
];
27+
yield [
28+
true,
29+
'YmFy'
30+
];
31+
yield [
32+
true,
33+
'VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZy4='
34+
];
35+
yield [
36+
true,
37+
'bGFuZ3VhZ2U6IHBocAoKZGlzdDogJ3RydXN0eScKCnBocDoKICAtICc3LjInCiAgLSAnNy4zJw' .
3838
'oKY2FjaGU6CiAgZGlyZWN0b3JpZXM6CiAgICAtIC4vdmVuZG9yCgppbnN0YWxsOgogIC0gY29tcG9zZX' .
3939
'IgaW5zdGFsbAoKc2NyaXB0OiB2ZW5kb3IvYmluL3BocHVuaXQK'
40-
],
41-
[
42-
true,
43-
'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAQAAAD8x0bcAAAAT0lEQVR4AbXRQQrAMAgF0d7' .
40+
];
41+
yield [
42+
true,
43+
'iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAQAAAD8x0bcAAAAT0lEQVR4AbXRQQrAMAgF0d7' .
4444
'J+5/NggjTT5lNIOPSt4l5PvVOlmBTyHLxnwFqZmAwUMNARmBHqIIoKkHK/HWQQHpMO2gsleUH' .
4545
'w6w7DOQNeQHgxcBzQQpFawAAAABJRU5ErkJggg=='
46-
],
47-
[
48-
false,
49-
'foo'
50-
],
51-
[
52-
false,
53-
'bar'
54-
],
55-
[
56-
false,
57-
'VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZy='
58-
],
59-
[
60-
false,
61-
'bGFuZ3VhZ2U6IHBocAoKZGlzdDogJ3RydXN0eScKCnBocDoKICAtICc3xx'
62-
],
63-
[
64-
false,
65-
'iVBORw0KGgoAAAANSUhEUgAAABIAAAAsCcAQAAAD8x0bcAAAaT0lEQVR4AbXRQQrAMAgF0d7J+5/NggjTT5lNIOPSt4' .
46+
];
47+
yield [
48+
false,
49+
'foo'
50+
];
51+
yield [
52+
false,
53+
'bar'
54+
];
55+
yield [
56+
false,
57+
'VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZy='
58+
];
59+
yield [
60+
false,
61+
'bGFuZ3VhZ2U6IHBocAoKZGlzdDogJ3RydXN0eScKCnBocDoKICAtICc3xx'
62+
];
63+
yield [
64+
false,
65+
'iVBORw0KGgoAAAANSUhEUgAAABIAAAAsCcAQAAAD8x0bcAAAaT0lEQVR4AbXRQQrAMAgF0d7J+5/NggjTT5lNIOPSt4' .
6666
'l5PvVOlmBTyHLxnwFqZmAwUMNARmBHqIIoKkHK/HWQQHpMO2gsleUHw6w7DOQNeQHgxcBzQQpFawAAAABJRU5ErkJggg=='
67-
],
6867
];
6968
}
7069
}

tests/Rules/BicTest.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Intervention\Validation\Tests\Rules;
66

7+
use Generator;
78
use PHPUnit\Framework\Attributes\DataProvider;
89
use Intervention\Validation\Rules\Bic;
910
use PHPUnit\Framework\TestCase;
@@ -17,17 +18,15 @@ public function testValidation($result, $value): void
1718
$this->assertEquals($result, $valid);
1819
}
1920

20-
public static function dataProvider(): array
21+
public static function dataProvider(): Generator
2122
{
22-
return [
23-
[true, 'PBNKDEFF'],
24-
[true, 'NOLADE21SHO'],
25-
[false, 'foobar'],
26-
[false, 'xxx'],
27-
[false, 'ABNFDBF'],
28-
[false, 'GR82WEST'],
29-
[false, '5070081'],
30-
[false, 'DEUTDBBER'],
31-
];
23+
yield [true, 'PBNKDEFF'];
24+
yield [true, 'NOLADE21SHO'];
25+
yield [false, 'foobar'];
26+
yield [false, 'xxx'];
27+
yield [false, 'ABNFDBF'];
28+
yield [false, 'GR82WEST'];
29+
yield [false, '5070081'];
30+
yield [false, 'DEUTDBBER'];
3231
}
3332
}

tests/Rules/CamelcaseTest.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Intervention\Validation\Tests\Rules;
66

7+
use Generator;
78
use PHPUnit\Framework\Attributes\DataProvider;
89
use Intervention\Validation\Rules\Camelcase;
910
use PHPUnit\Framework\TestCase;
@@ -17,24 +18,22 @@ public function testValidation($result, $value): void
1718
$this->assertEquals($result, $valid);
1819
}
1920

20-
public static function dataProvider(): array
21+
public static function dataProvider(): Generator
2122
{
22-
return [
23-
[true, 'foo'],
24-
[true, 'Foo'],
25-
[true, 'fooBar'],
26-
[true, 'fooBarBaz'],
27-
[true, 'fooBarBâz'],
28-
[true, 'fOo'],
29-
[true, 'PostScript'],
30-
[true, 'iPhone'],
31-
[false, 'foobaR'],
32-
[false, 'FoobaR'],
33-
[false, 'FOo'],
34-
[false, 'FOO'],
35-
[false, 'fo0bar'],
36-
[false, '-fooBar'],
37-
[false, '-fooBar-'],
38-
];
23+
yield [true, 'foo'];
24+
yield [true, 'Foo'];
25+
yield [true, 'fooBar'];
26+
yield [true, 'fooBarBaz'];
27+
yield [true, 'fooBarBâz'];
28+
yield [true, 'fOo'];
29+
yield [true, 'PostScript'];
30+
yield [true, 'iPhone'];
31+
yield [false, 'foobaR'];
32+
yield [false, 'FoobaR'];
33+
yield [false, 'FOo'];
34+
yield [false, 'FOO'];
35+
yield [false, 'fo0bar'];
36+
yield [false, '-fooBar'];
37+
yield [false, '-fooBar-'];
3938
}
4039
}

tests/Rules/CidrTest.php

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Intervention\Validation\Tests\Rules;
66

7+
use Generator;
78
use PHPUnit\Framework\Attributes\DataProvider;
89
use Intervention\Validation\Rules\Cidr;
910
use PHPUnit\Framework\TestCase;
@@ -17,20 +18,18 @@ public function testValidation($result, $value): void
1718
$this->assertEquals($result, $valid);
1819
}
1920

20-
public static function dataProvider(): array
21+
public static function dataProvider(): Generator
2122
{
22-
return [
23-
[true, '0.0.0.0/0'],
24-
[true, '10.0.0.0/8'],
25-
[true, '1.1.1.1/32'],
26-
[true, '192.168.1.0/24'],
27-
[true, '192.168.1.1/24'],
28-
[false, '192.168.1.1'],
29-
[false, '1.1.1.1/3.14'],
30-
[false, '1.1.1.1/33'],
31-
[false, '1.1.1.1/100'],
32-
[false, '1.1.1.1/-3'],
33-
[false, '1.1.1/3'],
34-
];
23+
yield [true, '0.0.0.0/0'];
24+
yield [true, '10.0.0.0/8'];
25+
yield [true, '1.1.1.1/32'];
26+
yield [true, '192.168.1.0/24'];
27+
yield [true, '192.168.1.1/24'];
28+
yield [false, '192.168.1.1'];
29+
yield [false, '1.1.1.1/3.14'];
30+
yield [false, '1.1.1.1/33'];
31+
yield [false, '1.1.1.1/100'];
32+
yield [false, '1.1.1.1/-3'];
33+
yield [false, '1.1.1/3'];
3534
}
3635
}

tests/Rules/CreditcardTest.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Intervention\Validation\Tests\Rules;
66

7+
use Generator;
78
use PHPUnit\Framework\Attributes\DataProvider;
89
use Intervention\Validation\Rules\Creditcard;
910
use PHPUnit\Framework\TestCase;
@@ -17,15 +18,13 @@ public function testValidation($result, $value): void
1718
$this->assertEquals($result, $valid);
1819
}
1920

20-
public static function dataProvider(): array
21+
public static function dataProvider(): Generator
2122
{
22-
return [
23-
[true, '4444111122223333'],
24-
[false, '9182819264532375'],
25-
[false, '12'],
26-
[false, '5555111122223333'],
27-
[false, 'xxxxxxxxxxxxxxxx'],
28-
[false, '4444111I22223333'],
29-
];
23+
yield [true, '4444111122223333'];
24+
yield [false, '9182819264532375'];
25+
yield [false, '12'];
26+
yield [false, '5555111122223333'];
27+
yield [false, 'xxxxxxxxxxxxxxxx'];
28+
yield [false, '4444111I22223333'];
3029
}
3130
}

0 commit comments

Comments
 (0)