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

MaxLengthTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
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 MaxLengthTest extends ConfiguredConstraintTestCase
10
{
11
    public function testEmptyConfiguration(): void
12
    {
13
        $this->expectException(MissingOptionsException::class);
14
15
        new ParsleyAssert\MaxLength();
16
    }
17
18
    public function testInvalidConfiguration(): void
19
    {
20
        $this->expectException(InvalidOptionsException::class);
21
22
        new ParsleyAssert\MaxLength([
23
            'max' => '10',
24
        ]);
25
    }
26
27
    public function testNormalization(): void
28
    {
29
        $constraint = new ParsleyAssert\MaxLength([
30
            'max' => 10,
31
        ]);
32
33
        $this->assertSame([
34
            'data-parsley-maxlength' => '10',
35
            'data-parsley-maxlength-message' => 'Invalid.',
36
            'maxlength' => '10',
37
        ], $constraint->normalize($this->normalizer));
38
    }
39
}
40