Passed
Branch master (d8ab5e)
by Max
05:15 queued 02:56
created

RegularExpressionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 8
c 3
b 0
f 0
dl 0
loc 21
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testClassExistence() 0 3 1
A testCreateSearchPatternFunction() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EasyDictionary;
6
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * @coversDefaultClass \EasyDictionary\RegularExpression
11
 */
12
class RegularExpressionTest extends TestCase
13
{
14
    /**
15
     * @covers \EasyDictionary\RegularExpression
16
     */
17
    public function testClassExistence()
18
    {
19
        self::assertTrue(class_exists('\EasyDictionary\RegularExpression'));
20
    }
21
22
    /**
23
     * @covers ::createSearchPattern
24
     */
25
    public function testCreateSearchPatternFunction()
26
    {
27
        self::assertEquals('/(one)/i', RegularExpression::createSearchPattern('one'));
28
        self::assertEquals('/(one)|(two)/i', RegularExpression::createSearchPattern('one,two'));
29
        self::assertEquals('/(one)|(two)/i', RegularExpression::createSearchPattern(['one', 'two']));
30
        self::assertEquals(
31
            '/((\s+)?one(\s+)?)/i',
32
            RegularExpression::createSearchPattern(['one'], true)
33
        );
34
    }
35
}
36