-
-
Notifications
You must be signed in to change notification settings - Fork 336
/
RectorAssertTest.php
126 lines (111 loc) · 2.99 KB
/
RectorAssertTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
declare(strict_types=1);
namespace Rector\Core\Tests\Validation;
use Iterator;
use PHPUnit\Framework\TestCase;
use Rector\Core\Validation\RectorAssert;
use Webmozart\Assert\InvalidArgumentException;
final class RectorAssertTest extends TestCase
{
/**
* @doesNotPerformAssertions
* @dataProvider provideDataValidClassNames()
*/
public function testValidClasNames(string $className): void
{
RectorAssert::className($className);
}
/**
* @dataProvider provideDataInvalidClassNames()
*/
public function testInvalidClasNames(string $className): void
{
$this->expectException(InvalidArgumentException::class);
RectorAssert::className($className);
}
/**
* @return Iterator<string[]>
*/
public function provideDataValidClassNames(): Iterator
{
yield ['App'];
yield ['App\\SomeClass'];
}
/**
* @return Iterator<string[]>
*/
public function provideDataInvalidClassNames(): Iterator
{
yield ['App Some'];
yield ['App$SomeClass'];
yield ['$SomeClass'];
yield ['App\\\\Some'];
yield ['3AppSome'];
}
/**
* @doesNotPerformAssertions
* @dataProvider provideDataValidFunctionNames()
*/
public function testValidFunctionName(string $functionName): void
{
RectorAssert::functionName($functionName);
}
/**
* @return Iterator<string[]>
*/
public function provideDataValidFunctionNames(): Iterator
{
yield ['some_function'];
yield ['Namespace\\some_function'];
yield ['Namespace\\so3me_f6n'];
}
/**
* @doesNotPerformAssertions
* @dataProvider provideDataValidMehtodNames()
*/
public function testValidMethodName(string $methodName): void
{
RectorAssert::methodName($methodName);
}
/**
* @return Iterator<string[]>
*/
public function provideDataValidMehtodNames(): Iterator
{
yield ['some_method'];
yield ['__method_magic'];
yield ['__M3th0d'];
}
/**
* @dataProvider provideDataInvalidFunctionNames()
*/
public function testInvalidFunctionName(string $functionName): void
{
$this->expectException(InvalidArgumentException::class);
RectorAssert::functionName($functionName);
}
public function provideDataInvalidFunctionNames(): Iterator
{
yield ['35'];
yield ['/function'];
yield ['$function'];
yield ['-key_name'];
}
/**
* @dataProvider provideDataInvalidNamespaceNames()
*/
public function testNamespaceName(string $namespaceName): void
{
$this->expectException(InvalidArgumentException::class);
RectorAssert::namespaceName($namespaceName);
}
/**
* @return Iterator<string[]>
*/
public function provideDataInvalidNamespaceNames(): Iterator
{
yield ['321Namespace'];
yield ['$__Namespace'];
yield ['Name*space'];
}
}