Code Duplication    Length = 7-9 lines in 8 locations

tests/Constraint/ItemsConstraintTest.php 2 locations

@@ 47-55 (lines=9) @@
44
        $this->getConstraint()->normalize($schema, new Context(), $this->mockWalker());
45
    }
46
47
    public function testNormalizeEnsuresItemsObjectIsAValidSchema()
48
    {
49
        $schema = $this->loadSchema('valid/items-object');
50
        $walker = $this->mockWalker();
51
        $walker->expects($this->at(0))
52
            ->method('parseSchema')
53
            ->with($schema->items);
54
        $this->getConstraint()->normalize($schema, new Context(), $walker);
55
    }
56
57
    public function testNormalizeThrowsIfItemsElementIsNotObject()
58
    {
@@ 84-92 (lines=9) @@
81
        $this->getConstraint()->normalize($schema, new Context(), $this->mockWalker());
82
    }
83
84
    public function testNormalizeEnsuresAdditionalItemsAsObjectIsAValidSchema()
85
    {
86
        $schema = $this->loadSchema('valid/additionalItems-object');
87
        $walker = $this->mockWalker();
88
        $walker->expects($this->at(1))
89
            ->method('parseSchema')
90
            ->with($schema->additionalItems);
91
        $this->getConstraint()->normalize($schema, new Context(), $walker);
92
    }
93
94
    protected function getConstraint()
95
    {

tests/Constraint/NotConstraintTest.php 1 location

@@ 24-32 (lines=9) @@
21
        $this->getConstraint()->normalize($schema, new Context(), $this->mockWalker());
22
    }
23
24
    public function testNormalizeEnsuresNotIsAValidSchema()
25
    {
26
        $schema = $this->loadSchema('valid/not-schema');
27
        $walker = $this->mockWalker();
28
        $walker->expects($this->at(0))
29
            ->method('parseSchema')
30
            ->with($schema->not);
31
        $this->getConstraint()->normalize($schema, new Context(), $walker);
32
    }
33
34
    protected function getConstraint()
35
    {

tests/Constraint/PatternConstraintTest.php 1 location

@@ 31-37 (lines=7) @@
28
        $this->getConstraint()->normalize($schema, new Context(), $this->mockWalker());
29
    }
30
31
    public function testDelimitersAreEscapedBeforeTestingRegex()
32
    {
33
        $schema = $this->loadSchema('valid/pattern-with-slash');
34
        $context = new Context();
35
        $this->getConstraint()->normalize($schema, $context, $this->mockWalker());
36
        $this->assertEquals(0, $context->countViolations());
37
    }
38
39
    protected function getConstraint()
40
    {

tests/Constraint/PropertiesTest.php 4 locations

@@ 55-63 (lines=9) @@
52
        $this->getConstraint()->normalize($schema, new Context(), $this->mockWalker());
53
    }
54
55
    public function testNormalizeEnsuresPropertiesPropertyIsAValidSchema()
56
    {
57
        $schema = $this->loadSchema('valid/properties-not-empty');
58
        $walker = $this->mockWalker();
59
        $walker->expects($this->at(0))
60
            ->method('parseSchema')
61
            ->with($schema->properties->foo);
62
        $this->getConstraint()->normalize($schema, new Context(), $walker);
63
    }
64
65
    public function testNormalizeThrowsIfAdditionalPropertiesIsNotBooleanOrObject()
66
    {
@@ 72-80 (lines=9) @@
69
        $this->getConstraint()->normalize($schema, new Context(), $this->mockWalker());
70
    }
71
72
    public function testNormalizeEnsuresAdditionalPropertiesAsObjectIsAValidSchema()
73
    {
74
        $schema = $this->loadSchema('valid/additionalProperties-as-object');
75
        $walker = $this->mockWalker();
76
        $walker->expects($this->at(0))
77
            ->method('parseSchema')
78
            ->with($schema->additionalProperties);
79
        $this->getConstraint()->normalize($schema, new Context(), $walker);
80
    }
81
82
    public function testNormalizeThrowsIfPatternPropertiesIsNotAnObject()
83
    {
@@ 103-111 (lines=9) @@
100
        $this->getConstraint()->normalize($schema, new Context(), $this->mockWalker());
101
    }
102
103
    public function testNormalizeEnsuresPatternPropertiesPropertyValueIsAValidSchema()
104
    {
105
        $schema = $this->loadSchema('valid/patternProperties-not-empty');
106
        $walker = $this->mockWalker();
107
        $walker->expects($this->at(1))
108
            ->method('parseSchema')
109
            ->with($schema->patternProperties->regex);
110
        $this->getConstraint()->normalize($schema, new Context(), $walker);
111
    }
112
113
    public function testDelimitersInPatternPropertiesAreEscapedBeforeTestingRegex()
114
    {
@@ 113-119 (lines=7) @@
110
        $this->getConstraint()->normalize($schema, new Context(), $walker);
111
    }
112
113
    public function testDelimitersInPatternPropertiesAreEscapedBeforeTestingRegex()
114
    {
115
        $schema = $this->loadSchema('valid/patternProperties-with-slash');
116
        $context = new Context();
117
        $this->getConstraint()->normalize($schema, $context, $this->mockWalker());
118
        $this->assertEquals(0, $context->countViolations());
119
    }
120
121
    protected function getConstraint()
122
    {