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

PregTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 13
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testMatchThrowsOnInvalidPattern() 0 5 1
A testMatch() 0 4 1
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