Failed Conditions
Branch ignore-unknown-keywords (efa676)
by Stéphane
02:58
created

testNormalizeThrowsIfEnumElementsAreNotUnique()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the JVal package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace JVal\Constraint;
11
12
use JVal\Context;
13
use JVal\Testing\ConstraintTestCase;
14
15
class EnumConstraintTest extends ConstraintTestCase
16
{
17
    public function testNormalizeThrowsIfEnumIsNotArray()
18
    {
19
        $this->expectConstraintException('InvalidTypeException', '/enum');
20
        $schema = $this->loadSchema('invalid/enum-not-array');
21
        $this->getConstraint()->normalize($schema, new Context(), $this->mockWalker());
22
    }
23
24
    public function testNormalizeThrowsIfEnumIsEmpty()
25
    {
26
        $this->expectConstraintException('EmptyArrayException', '/enum');
27
        $schema = $this->loadSchema('invalid/enum-empty');
28
        $this->getConstraint()->normalize($schema, new Context(), $this->mockWalker());
29
    }
30
31
    public function testNormalizeThrowsIfEnumElementsAreNotUnique()
32
    {
33
        $this->expectConstraintException('NotUniqueException', '/enum');
34
        $schema = $this->loadSchema('invalid/enum-elements-not-unique');
35
        $this->getConstraint()->normalize($schema, new Context(), $this->mockWalker());
36
    }
37
38
    protected function getConstraint()
39
    {
40
        return new EnumConstraint();
41
    }
42
43
    protected function getCaseFileNames()
44
    {
45
        return ['enum'];
46
    }
47
}
48