/
ErrorTest.php
59 lines (50 loc) · 1.21 KB
/
ErrorTest.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
<?php declare(strict_types = 1);
namespace PHPStan\Analyser;
use PHPStan\Testing\PHPStanTestCase;
class ErrorTest extends PHPStanTestCase
{
public function testError(): void
{
$error = new Error('Message', 'file', 10);
$this->assertSame('Message', $error->getMessage());
$this->assertSame('file', $error->getFile());
$this->assertSame(10, $error->getLine());
}
public function dataValidIdentifier(): iterable
{
yield ['a'];
yield ['aa'];
yield ['phpstan'];
yield ['phpstan.internal'];
yield ['phpstan.alwaysFail'];
yield ['Phpstan.alwaysFail'];
yield ['phpstan.internal.foo'];
yield ['foo2.test'];
yield ['phpstan123'];
yield ['3m.blah'];
}
/**
* @dataProvider dataValidIdentifier
*/
public function testValidIdentifier(string $identifier): void
{
$this->assertTrue(Error::validateIdentifier($identifier));
}
public function dataInvalidIdentifier(): iterable
{
yield [''];
yield [' '];
yield ['phpstan '];
yield [' phpstan'];
yield ['.phpstan'];
yield ['phpstan.'];
yield ['.'];
}
/**
* @dataProvider dataInvalidIdentifier
*/
public function testInvalidIdentifier(string $identifier): void
{
$this->assertFalse(Error::validateIdentifier($identifier));
}
}