Code Duplication    Length = 36-38 lines in 5 locations

tests/RestrictionsTest.php 5 locations

@@ 12-47 (lines=36) @@
9
    /**
10
     * Test the correct detection an Enumeration-restriction.
11
     */
12
    public function testRestriction_1()
13
    {
14
        $schema = $this->reader->readString(
15
            '
16
            <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
17
18
                <xs:element name="enumeration">
19
                    <xs:simpleType>
20
                        <xs:restriction base="xs:string">
21
                            <xs:enumeration value="foo"/>
22
                            <xs:enumeration value="bar"/>
23
                        </xs:restriction>
24
                  </xs:simpleType>
25
                </xs:element>
26
27
            </xs:schema>');
28
29
        $element = $schema->findElement('enumeration', 'http://www.example.com');
30
        $simpleType = $element->getType();
31
        $restriction = $simpleType->getRestriction();
32
        $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Inheritance\Restriction', $restriction);
33
34
        $expectedChecks = array(
35
            'enumeration' => array(
36
                array(
37
                    'value' => 'foo',
38
                    'doc' => '',
39
                ),
40
                array(
41
                    'value' => 'bar',
42
                    'doc' => '',
43
                ),
44
            ),
45
        );
46
        $this->assertEquals($expectedChecks, $restriction->getChecks());
47
    }
48
49
    /**
50
     * Test the correct detection a pattern-restriction.
@@ 122-159 (lines=38) @@
119
    /**
120
     * Test the correct detection a minLength- and maxLength-restriction.
121
     */
122
    public function testRestriction_4()
123
    {
124
        $schema = $this->reader->readString(
125
            '
126
            <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
127
128
                <xs:element name="minMaxLength">
129
                    <xs:simpleType>
130
                        <xs:restriction base="xs:string">
131
                            <xs:minLength value="5"/>
132
                            <xs:maxLength value="8"/>
133
                        </xs:restriction>
134
                    </xs:simpleType>
135
                </xs:element>
136
137
            </xs:schema>');
138
139
        $element = $schema->findElement('minMaxLength', 'http://www.example.com');
140
        $simpleType = $element->getType();
141
        $restriction = $simpleType->getRestriction();
142
        $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Inheritance\Restriction', $restriction);
143
144
        $expectedChecks = array(
145
            'minLength' => array(
146
                array(
147
                    'value' => '5',
148
                    'doc' => '',
149
                ),
150
            ),
151
            'maxLength' => array(
152
                array(
153
                    'value' => '8',
154
                    'doc' => '',
155
                ),
156
            ),
157
        );
158
        $this->assertEquals($expectedChecks, $restriction->getChecks());
159
    }
160
161
    /**
162
     * Test the correct detection a minInclusive- and maxInclusive-restriction.
@@ 164-201 (lines=38) @@
161
    /**
162
     * Test the correct detection a minInclusive- and maxInclusive-restriction.
163
     */
164
    public function testRestriction_5()
165
    {
166
        $schema = $this->reader->readString(
167
            '
168
            <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
169
170
                <xs:element name="minMaxInclusive">
171
                    <xs:simpleType>
172
                        <xs:restriction base="xs:integer">
173
                            <xs:minInclusive value="1"/>
174
                            <xs:maxInclusive value="10"/>
175
                        </xs:restriction>
176
                    </xs:simpleType>
177
                </xs:element>
178
179
            </xs:schema>');
180
181
        $element = $schema->findElement('minMaxInclusive', 'http://www.example.com');
182
        $simpleType = $element->getType();
183
        $restriction = $simpleType->getRestriction();
184
        $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Inheritance\Restriction', $restriction);
185
186
        $expectedChecks = array(
187
            'minInclusive' => array(
188
                array(
189
                    'value' => '1',
190
                    'doc' => '',
191
                ),
192
            ),
193
            'maxInclusive' => array(
194
                array(
195
                    'value' => '10',
196
                    'doc' => '',
197
                ),
198
            ),
199
        );
200
        $this->assertEquals($expectedChecks, $restriction->getChecks());
201
    }
202
203
    /**
204
     * Test the correct detection a minExclusive- and maxExclusive-restriction.
@@ 206-243 (lines=38) @@
203
    /**
204
     * Test the correct detection a minExclusive- and maxExclusive-restriction.
205
     */
206
    public function testRestriction_6()
207
    {
208
        $schema = $this->reader->readString(
209
            '
210
            <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
211
212
                <xs:element name="minMaxExclusive">
213
                    <xs:simpleType>
214
                        <xs:restriction base="xs:integer">
215
                            <xs:minExclusive value="1"/>
216
                            <xs:maxExclusive value="10"/>
217
                        </xs:restriction>
218
                    </xs:simpleType>
219
                </xs:element>
220
221
            </xs:schema>');
222
223
        $element = $schema->findElement('minMaxExclusive', 'http://www.example.com');
224
        $simpleType = $element->getType();
225
        $restriction = $simpleType->getRestriction();
226
        $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Inheritance\Restriction', $restriction);
227
228
        $expectedChecks = array(
229
            'minExclusive' => array(
230
                array(
231
                    'value' => '1',
232
                    'doc' => '',
233
                ),
234
            ),
235
            'maxExclusive' => array(
236
                array(
237
                    'value' => '10',
238
                    'doc' => '',
239
                ),
240
            ),
241
        );
242
        $this->assertEquals($expectedChecks, $restriction->getChecks());
243
    }
244
245
    /**
246
     * Test the correct detection a fractionDigits-restriction.
@@ 318-355 (lines=38) @@
315
    /**
316
     * Test the correct detection a totalDigits- and fractionDigits-restriction.
317
     */
318
    public function testRestriction_9()
319
    {
320
        $schema = $this->reader->readString(
321
            '
322
            <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
323
324
                <xs:element name="totalFractionDigits">
325
                    <xs:simpleType>
326
                        <xs:restriction base="xs:decimal">
327
                            <xs:totalDigits value="4"/>
328
                            <xs:fractionDigits value="2"/>
329
                        </xs:restriction>
330
                    </xs:simpleType>
331
                </xs:element>
332
333
            </xs:schema>');
334
335
        $element = $schema->findElement('totalFractionDigits', 'http://www.example.com');
336
        $simpleType = $element->getType();
337
        $restriction = $simpleType->getRestriction();
338
        $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Inheritance\Restriction', $restriction);
339
340
        $expectedChecks = array(
341
            'totalDigits' => array(
342
                array(
343
                    'value' => '4',
344
                    'doc' => '',
345
                ),
346
            ),
347
            'fractionDigits' => array(
348
                array(
349
                    'value' => '2',
350
                    'doc' => '',
351
                ),
352
            ),
353
        );
354
        $this->assertEquals($expectedChecks, $restriction->getChecks());
355
    }
356
357
    /**
358
     * Test the correct detection a whiteSpace-restriction.