Completed
Pull Request — master (#247)
by Jaap
11:03 queued 01:08
created

PcreExceptionTest::testErrorConversion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace phpDocumentor\Reflection\Exception;
6
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * @coversDefaultClass \phpDocumentor\Reflection\Exception\PcreException
11
 */
12
final class PcreExceptionTest extends TestCase
13
{
14
    /**
15
     * @covers ::createFromPhpError
16
     *
17
     * @dataProvider errorCodeProvider
18
     */
19
    public function testErrorConversion(int $errorCode, string $message)
20
    {
21
        $this->assertSame($message, PcreException::createFromPhpError($errorCode)->getMessage());
22
    }
23
24
    public function errorCodeProvider()
25
    {
26
        return [
27
            [
28
                PREG_BACKTRACK_LIMIT_ERROR,
29
                'Backtrack limit error'
30
            ],
31
            [
32
                PREG_RECURSION_LIMIT_ERROR,
33
                'Recursion limit error',
34
            ],
35
            [
36
                PREG_BAD_UTF8_ERROR,
37
                'Bad UTF8 error',
38
            ],
39
            [
40
                PREG_BAD_UTF8_OFFSET_ERROR,
41
                'Bad UTF8 offset error',
42
            ],
43
            [
44
                PREG_JIT_STACKLIMIT_ERROR,
45
                'Jit stacklimit error',
46
            ],
47
            [
48
                PREG_NO_ERROR,
49
                'Unknown Pcre error',
50
            ],
51
            [
52
                PREG_INTERNAL_ERROR,
53
                'Unknown Pcre error'
54
            ]
55
        ];
56
    }
57
}
58