Passed
Pull Request — master (#416)
by Sergei
04:39 queued 01:56
created

EmailTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 26
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetName() 0 4 1
A testWhen() 0 4 1
A getDifferentRuleInHandlerItems() 0 3 1
A testSkipOnError() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Tests\Rule;
6
7
use PHPUnit\Framework\TestCase;
8
use Yiisoft\Validator\Rule\Email;
9
use Yiisoft\Validator\Rule\EmailHandler;
10
use Yiisoft\Validator\Tests\Rule\Base\DifferentRuleInHandlerTestTrait;
11
use Yiisoft\Validator\Tests\Rule\Base\SkipOnErrorTestTrait;
12
use Yiisoft\Validator\Tests\Rule\Base\WhenTestTrait;
13
14
final class EmailTest extends TestCase
15
{
16
    use DifferentRuleInHandlerTestTrait;
17
    use SkipOnErrorTestTrait;
18
    use WhenTestTrait;
19
20
    public function testGetName(): void
21
    {
22
        $rule = new Email();
23
        $this->assertSame('email', $rule->getName());
24
    }
25
26
    public function testSkipOnError(): void
27
    {
28
        $this->testSkipOnErrorInternal(new Email(), new Email(skipOnError: true));
29
    }
30
31
    public function testWhen(): void
32
    {
33
        $when = static fn (mixed $value): bool => $value !== null;
34
        $this->testWhenInternal(new Email(), new Email(when: $when));
35
    }
36
37
    protected function getDifferentRuleInHandlerItems(): array
38
    {
39
        return [Email::class, EmailHandler::class];
40
    }
41
}
42