Completed
Push — master ( ed4843...c0d0bb )
by Vincenzo
02:12
created

testItReturnsNullOnMatchOneWhereNoMatch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
4
use App\Lib\Helpers\RegExp;
5
6
class RegExpTest extends PHPUnit_Framework_TestCase
7
{
8
9
    /**
10
     * @group Helpers
11
     * @group Regexp
12
     */
13
    public function testItReturnsRightMatchOnMatchOne()
14
    {
15
        $text = "stuffCiao1";
16
        $match = RegExp::getFirstMatch('/stuff(.+?)1/', $text);
17
        $this->assertEquals('Ciao', $match);
18
    }
19
20
    /**
21
     * @group Helpers
22
     * @group Regexp
23
     */
24
    public function testItReturnsNullOnMatchOneWhereNoMatch()
25
    {
26
        $text = "stuffCiao1";
27
        $match = RegExp::getFirstMatch('/stuff1(.+?)1/', $text);
28
        $this->assertNull($match);
29
    }
30
31
    /**
32
     * @group Helpers
33
     * @group Regexp
34
     * @group matchall
35
     */
36
    public function testItReturnsPregMatchesMatchAll()
37
    {
38
        $text = "stuffCiao1";
39
        $rgx = '/stuff(.+?)1/';
40
        $matchesPreg = [];
41
        preg_match_all($rgx, $text, $matchesPreg);
42
        $this->assertEquals($matchesPreg, RegExp::getAllMatch($rgx, $text));
43
    }
44
}
45