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

LessThanFactoryTest::setUpCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
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\FactoryInterface;
8
use JBen87\ParsleyBundle\Constraint\Factory\LessThanFactory;
9
use Symfony\Component\Validator\Constraint as SymfonyConstraint;
10
use Symfony\Component\Validator\Constraints as Assert;
11
12
class LessThanFactoryTest extends FactoryTestCase
13
{
14
    private const VALUE = 10;
15
    private const ORIGINAL_MESSAGE = 'This value should be less than {{ compared_value }}.';
16
    private const TRANSLATED_MESSAGE = 'This value should be less than '.self::VALUE.'.';
17
18
    /**
19
     * @inheritdoc
20
     */
21
    protected function setUpCreate(): void
22
    {
23
        $this->translator
24
            ->expects($this->once())
25
            ->method('trans')
26
            ->with(static::ORIGINAL_MESSAGE)
27
            ->willReturn(static::TRANSLATED_MESSAGE)
28
        ;
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    protected function getExpectedConstraint(): Constraint
35
    {
36
        return new ParsleyAssert\LessThan(['value' => static::VALUE, 'message' => static::TRANSLATED_MESSAGE]);
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42
    protected function getOriginalConstraint(): SymfonyConstraint
43
    {
44
        return new Assert\LessThan(static::VALUE);
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    protected function getUnsupportedConstraint(): SymfonyConstraint
51
    {
52
        return new Assert\Valid();
53
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58
    protected function createFactory(): FactoryInterface
59
    {
60
        return new LessThanFactory();
61
    }
62
}
63