Passed
Push — master ( e73618...52f31e )
by Alexander
17:03 queued 10:18
created

MatchRegularExpressionTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 13
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testValidate() 0 11 1
1
<?php
2
3
namespace Yiisoft\Validator\Tests\Rule;
4
5
use PHPUnit\Framework\TestCase;
6
use Yiisoft\Validator\Rule\MatchRegularExpression;
7
8
/**
9
 * @group validators
10
 */
11
class MatchRegularExpressionTest extends TestCase
12
{
13
    public function testValidate(): void
14
    {
15
        $rule = new MatchRegularExpression('/^[a-zA-Z0-9](\.)?([^\/]*)$/m');
16
        $this->assertTrue($rule->validate('b.4')->isValid());
17
        $this->assertFalse($rule->validate('b./')->isValid());
18
        $this->assertFalse($rule->validate(['a', 'b'])->isValid());
19
20
        $rule = (new MatchRegularExpression('/^[a-zA-Z0-9](\.)?([^\/]*)$/m'))->not();
21
        $this->assertFalse($rule->validate('b.4')->isValid());
22
        $this->assertTrue($rule->validate('b./')->isValid());
23
        $this->assertFalse($rule->validate(['a', 'b'])->isValid());
24
    }
25
}
26