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

LengthTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3
1
<?php
2
3
namespace JBen87\ParsleyBundle\Tests\Constraint\Constraints;
4
5
use JBen87\ParsleyBundle\Constraint\Constraints as ParsleyAssert;
6
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
7
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException;
8
9
class LengthTest extends ConfiguredConstraintTestCase
10
{
11
    public function testEmptyConfiguration(): void
12
    {
13
        $this->expectException(MissingOptionsException::class);
14
15
        new ParsleyAssert\Length();
16
    }
17
18
    public function testInvalidConfiguration(): void
19
    {
20
        $this->expectException(InvalidOptionsException::class);
21
22
        new ParsleyAssert\Length([
23
            'min' => '5',
24
            'max' => '10',
25
        ]);
26
    }
27
28
    public function testNormalization(): void
29
    {
30
        $constraint = new ParsleyAssert\Length([
31
            'min' => 5,
32
            'max' => 10,
33
        ]);
34
35
        $this->assertSame([
36
            'data-parsley-length' => '[5, 10]',
37
            'data-parsley-length-message' => 'Invalid.',
38
        ], $constraint->normalize($this->normalizer));
39
    }
40
}
41