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

GreaterThanFactoryTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 49
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\FactoryInterface;
8
use JBen87\ParsleyBundle\Constraint\Factory\GreaterThanFactory;
9
use Symfony\Component\Validator\Constraint as SymfonyConstraint;
10
use Symfony\Component\Validator\Constraints as Assert;
11
12
class GreaterThanFactoryTest extends FactoryTestCase
13
{
14
    private const VALUE = 10;
15
    private const ORIGINAL_MESSAGE = 'This value should be greater than {{ compared_value }}.';
16
    private const TRANSLATED_MESSAGE = 'This value should be greater 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\GreaterThan(['value' => static::VALUE, 'message' => static::TRANSLATED_MESSAGE]);
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42
    protected function getOriginalConstraint(): SymfonyConstraint
43
    {
44
        return new Assert\GreaterThan(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 GreaterThanFactory();
61
    }
62
}
63