-
-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathRectorAssertTest.php
More file actions
102 lines (89 loc) · 2.61 KB
/
RectorAssertTest.php
File metadata and controls
102 lines (89 loc) · 2.61 KB
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
<?php
declare(strict_types=1);
namespace Rector\Tests\Validation;
use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use PHPUnit\Framework\TestCase;
use Rector\Validation\RectorAssert;
use Webmozart\Assert\InvalidArgumentException;
final class RectorAssertTest extends TestCase
{
#[DataProvider('provideDataValidClassNames')]
#[DoesNotPerformAssertions]
public function testValidClassNames(string $className): void
{
RectorAssert::className($className);
}
#[DataProvider('provideDataInvalidClassNames')]
public function testInvalidClassNames(string $className): void
{
$this->expectException(InvalidArgumentException::class);
RectorAssert::className($className);
}
/**
* @return Iterator<string[]>
*/
public static function provideDataValidClassNames(): Iterator
{
yield ['App'];
yield ['App\\SomeClass'];
}
/**
* @return Iterator<string[]>
*/
public static function provideDataInvalidClassNames(): Iterator
{
yield ['App Some'];
yield ['App$SomeClass'];
yield ['$SomeClass'];
yield ['App\\\\Some'];
yield ['3AppSome'];
}
#[DataProvider('provideDataValidFunctionNames')]
#[DoesNotPerformAssertions]
public function testValidFunctionName(string $functionName): void
{
RectorAssert::functionName($functionName);
}
/**
* @return Iterator<string[]>
*/
public static function provideDataValidFunctionNames(): Iterator
{
yield ['some_function'];
yield ['Namespace\\some_function'];
yield ['Namespace\\so3me_f6n'];
}
#[DataProvider('provideDataValidMethodNames')]
#[DoesNotPerformAssertions]
public function testValidMethodName(string $methodName): void
{
RectorAssert::methodName($methodName);
}
/**
* @return Iterator<string[]>
*/
public static function provideDataValidMethodNames(): Iterator
{
yield ['some_method'];
yield ['__method_magic'];
yield ['__M3th0d'];
}
#[DataProvider('provideDataInvalidFunctionNames')]
public function testInvalidFunctionName(string $functionName): void
{
$this->expectException(InvalidArgumentException::class);
RectorAssert::functionName($functionName);
}
/**
* @return Iterator<array<int, string>>
*/
public static function provideDataInvalidFunctionNames(): Iterator
{
yield ['35'];
yield ['/function'];
yield ['$function'];
yield ['-key_name'];
}
}