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

EmailTest::testWhen()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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