-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPatternCollectionTest.php
More file actions
43 lines (34 loc) · 1.57 KB
/
PatternCollectionTest.php
File metadata and controls
43 lines (34 loc) · 1.57 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
<?php
declare(strict_types=1);
namespace Rector\Behastan\Tests\ValueObject;
use PHPUnit\Framework\TestCase;
use Rector\Behastan\ValueObject\Pattern\ExactPattern;
use Rector\Behastan\ValueObject\Pattern\NamedPattern;
use Rector\Behastan\ValueObject\Pattern\RegexPattern;
use Rector\Behastan\ValueObject\PatternCollection;
final class PatternCollectionTest extends TestCase
{
public function testExactPatterns(): void
{
$patternCollection = new PatternCollection([
new ExactPattern('pattern1', 'file1.php', 10, 'SomeClass', 'someMethod'),
new ExactPattern('pattern2', 'file2.php', 20, 'AnotherClass', 'anotherMethod'),
new NamedPattern('this is :me', 'file1.php', 10, 'SomeClass', 'someMethod'),
]);
$this->assertSame(['pattern1', 'pattern2'], $patternCollection->exactPatternStrings());
}
public function testRegexPatterns(): void
{
$patternCollection = new PatternCollection([
new ExactPattern('pattern1', 'file1.php', 10, 'SomeClass', 'someMethod'),
new RegexPattern('#this is it#', 'file1.php', 10, 'SomeClass', 'someMethod'),
new RegexPattern('#here is more#', 'file1.php', 10, 'SomeClass', 'someMethod'),
]);
$this->assertSame(['#this is it#', '#here is more#'], $patternCollection->regexPatternsStrings());
}
public function testNamedPatterns(): void
{
$namedPattern = new NamedPattern('this is :me', 'file1.php', 10, 'SomeClass', 'someMethod');
$this->assertSame('#this is (.*?)#', $namedPattern->getRegexPattern());
}
}