Passed
Push — release/v2 ( 119cbe...817cd6 )
by Benoit
02:50
created

EmailFactoryTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 48
rs 10
c 0
b 0
f 0
wmc 5
1
<?php
2
3
namespace JBen87\ParsleyBundle\Tests\Constraint\Factory;
4
5
use JBen87\ParsleyBundle\Constraint\Constraint;
6
use JBen87\ParsleyBundle\Constraint\Constraints as ParsleyAssert;
7
use JBen87\ParsleyBundle\Constraint\Factory\EmailFactory;
8
use JBen87\ParsleyBundle\Constraint\Factory\FactoryInterface;
9
use Symfony\Component\Validator\Constraint as SymfonyConstraint;
10
use Symfony\Component\Validator\Constraints as Assert;
11
12
class EmailFactoryTest extends FactoryTestCase
13
{
14
    private const ORIGINAL_MESSAGE = 'This value is not a valid email address.';
15
    private const TRANSLATED_MESSAGE = 'This value is not a valid email address.';
16
17
    /**
18
     * @inheritdoc
19
     */
20
    protected function setUpCreate(): void
21
    {
22
        $this->translator
23
            ->expects($this->once())
24
            ->method('trans')
25
            ->with(static::ORIGINAL_MESSAGE)
26
            ->willReturn(static::TRANSLATED_MESSAGE)
27
        ;
28
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33
    protected function getExpectedConstraint(): Constraint
34
    {
35
        return new ParsleyAssert\Email(['message' => static::TRANSLATED_MESSAGE]);
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41
    protected function getOriginalConstraint(): SymfonyConstraint
42
    {
43
        return new Assert\Email();
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49
    protected function getUnsupportedConstraint(): SymfonyConstraint
50
    {
51
        return new Assert\Valid();
52
    }
53
54
    /**
55
     * @inheritdoc
56
     */
57
    protected function createFactory(): FactoryInterface
58
    {
59
        return new EmailFactory();
60
    }
61
}
62