Completed
Push — master ( d87057...f3ab30 )
by Jaap
28s queued 12s
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
use const PREG_BACKTRACK_LIMIT_ERROR;
9
use const PREG_BAD_UTF8_ERROR;
10
use const PREG_BAD_UTF8_OFFSET_ERROR;
11
use const PREG_INTERNAL_ERROR;
12
use const PREG_JIT_STACKLIMIT_ERROR;
13
use const PREG_NO_ERROR;
14
use const PREG_RECURSION_LIMIT_ERROR;
15
16
/**
17
 * @coversDefaultClass \phpDocumentor\Reflection\Exception\PcreException
18
 */
19
final class PcreExceptionTest extends TestCase
20
{
21
    /**
22
     * @covers ::createFromPhpError
23
     * @dataProvider errorCodeProvider
24
     */
25
    public function testErrorConversion(int $errorCode, string $message) : void
26
    {
27
        $this->assertSame($message, PcreException::createFromPhpError($errorCode)->getMessage());
28
    }
29
30
    /**
31
     * @return array<int, (string|int)[]>
32
     */
33
    public function errorCodeProvider() : array
34
    {
35
        return [
36
            [
37
                PREG_BACKTRACK_LIMIT_ERROR,
38
                'Backtrack limit error',
39
            ],
40
            [
41
                PREG_RECURSION_LIMIT_ERROR,
42
                'Recursion limit error',
43
            ],
44
            [
45
                PREG_BAD_UTF8_ERROR,
46
                'Bad UTF8 error',
47
            ],
48
            [
49
                PREG_BAD_UTF8_OFFSET_ERROR,
50
                'Bad UTF8 offset error',
51
            ],
52
            [
53
                PREG_JIT_STACKLIMIT_ERROR,
54
                'Jit stacklimit error',
55
            ],
56
            [
57
                PREG_NO_ERROR,
58
                'Unknown Pcre error',
59
            ],
60
            [
61
                PREG_INTERNAL_ERROR,
62
                'Unknown Pcre error',
63
            ],
64
        ];
65
    }
66
}
67