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

MaxLengthTest::testEmptyConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
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