Passed
Push — test ( d838cf...cef4a5 )
by Tom
03:29
created

PregTest::testMatchThrowsOnInvalidPattern()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines;
6
7
/**
8
 * @covers \Ktomk\Pipelines\Preg
9
 */
10
class PregTest extends TestCase
11
{
12
    public function testMatch()
13
    {
14
        self::assertSame(1, Preg::match('(^(?!-)[A-Za-z0-9._-]+$)', 'foo'));
15
        self::assertSame(0, Preg::match('(^(?!-)[A-Za-z0-9._-]+$)', '-foo'));
16
    }
17
18
    public function testMatchThrowsOnInvalidPattern()
19
    {
20
        $this->expectException('UnexpectedValueException');
21
        $this->expectExceptionMessageMatches('(preg_match error \(\d+\): "")');
22
        Preg::match('', '');
23
    }
24
}
25