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

RegExpTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testItReturnsRightMatchOnMatchOne() 0 6 1
A testItReturnsNullOnMatchOneWhereNoMatch() 0 6 1
A testItReturnsPregMatchesMatchAll() 0 8 1
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