@@ 52-82 (lines=31) @@ | ||
49 | /** |
|
50 | * Test the correct detection a pattern-restriction. |
|
51 | */ |
|
52 | public function testRestriction_2() |
|
53 | { |
|
54 | $schema = $this->reader->readString( |
|
55 | ' |
|
56 | <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|
57 | ||
58 | <xs:element name="pattern"> |
|
59 | <xs:simpleType> |
|
60 | <xs:restriction base="xs:string"> |
|
61 | <xs:pattern value="[a-zA-Z0-9]"/> |
|
62 | </xs:restriction> |
|
63 | </xs:simpleType> |
|
64 | </xs:element> |
|
65 | ||
66 | </xs:schema>'); |
|
67 | ||
68 | $element = $schema->findElement('pattern', 'http://www.example.com'); |
|
69 | $simpleType = $element->getType(); |
|
70 | $restriction = $simpleType->getRestriction(); |
|
71 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Inheritance\Restriction', $restriction); |
|
72 | ||
73 | $expectedChecks = array( |
|
74 | 'pattern' => array( |
|
75 | array( |
|
76 | 'value' => '[a-zA-Z0-9]', |
|
77 | 'doc' => '', |
|
78 | ), |
|
79 | ), |
|
80 | ); |
|
81 | $this->assertEquals($expectedChecks, $restriction->getChecks()); |
|
82 | } |
|
83 | ||
84 | /** |
|
85 | * Test the correct detection a length-restriction. |
|
@@ 87-117 (lines=31) @@ | ||
84 | /** |
|
85 | * Test the correct detection a length-restriction. |
|
86 | */ |
|
87 | public function testRestriction_3() |
|
88 | { |
|
89 | $schema = $this->reader->readString( |
|
90 | ' |
|
91 | <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|
92 | ||
93 | <xs:element name="length"> |
|
94 | <xs:simpleType> |
|
95 | <xs:restriction base="xs:string"> |
|
96 | <xs:length value="10"/> |
|
97 | </xs:restriction> |
|
98 | </xs:simpleType> |
|
99 | </xs:element> |
|
100 | ||
101 | </xs:schema>'); |
|
102 | ||
103 | $element = $schema->findElement('length', 'http://www.example.com'); |
|
104 | $simpleType = $element->getType(); |
|
105 | $restriction = $simpleType->getRestriction(); |
|
106 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Inheritance\Restriction', $restriction); |
|
107 | ||
108 | $expectedChecks = array( |
|
109 | 'length' => array( |
|
110 | array( |
|
111 | 'value' => '10', |
|
112 | 'doc' => '', |
|
113 | ), |
|
114 | ), |
|
115 | ); |
|
116 | $this->assertEquals($expectedChecks, $restriction->getChecks()); |
|
117 | } |
|
118 | ||
119 | /** |
|
120 | * Test the correct detection a minLength- and maxLength-restriction. |
|
@@ 248-278 (lines=31) @@ | ||
245 | /** |
|
246 | * Test the correct detection a fractionDigits-restriction. |
|
247 | */ |
|
248 | public function testRestriction_7() |
|
249 | { |
|
250 | $schema = $this->reader->readString( |
|
251 | ' |
|
252 | <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|
253 | ||
254 | <xs:element name="fractionDigits"> |
|
255 | <xs:simpleType> |
|
256 | <xs:restriction base="xs:decimal"> |
|
257 | <xs:fractionDigits value="2"/> |
|
258 | </xs:restriction> |
|
259 | </xs:simpleType> |
|
260 | </xs:element> |
|
261 | ||
262 | </xs:schema>'); |
|
263 | ||
264 | $element = $schema->findElement('fractionDigits', 'http://www.example.com'); |
|
265 | $simpleType = $element->getType(); |
|
266 | $restriction = $simpleType->getRestriction(); |
|
267 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Inheritance\Restriction', $restriction); |
|
268 | ||
269 | $expectedChecks = array( |
|
270 | 'fractionDigits' => array( |
|
271 | array( |
|
272 | 'value' => '2', |
|
273 | 'doc' => '', |
|
274 | ), |
|
275 | ), |
|
276 | ); |
|
277 | $this->assertEquals($expectedChecks, $restriction->getChecks()); |
|
278 | } |
|
279 | ||
280 | /** |
|
281 | * Test the correct detection a totalDigits-restriction. |
|
@@ 283-313 (lines=31) @@ | ||
280 | /** |
|
281 | * Test the correct detection a totalDigits-restriction. |
|
282 | */ |
|
283 | public function testRestriction_8() |
|
284 | { |
|
285 | $schema = $this->reader->readString( |
|
286 | ' |
|
287 | <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|
288 | ||
289 | <xs:element name="totalDigits"> |
|
290 | <xs:simpleType> |
|
291 | <xs:restriction base="xs:decimal"> |
|
292 | <xs:totalDigits value="4"/> |
|
293 | </xs:restriction> |
|
294 | </xs:simpleType> |
|
295 | </xs:element> |
|
296 | ||
297 | </xs:schema>'); |
|
298 | ||
299 | $element = $schema->findElement('totalDigits', 'http://www.example.com'); |
|
300 | $simpleType = $element->getType(); |
|
301 | $restriction = $simpleType->getRestriction(); |
|
302 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Inheritance\Restriction', $restriction); |
|
303 | ||
304 | $expectedChecks = array( |
|
305 | 'totalDigits' => array( |
|
306 | array( |
|
307 | 'value' => '4', |
|
308 | 'doc' => '', |
|
309 | ), |
|
310 | ), |
|
311 | ); |
|
312 | $this->assertEquals($expectedChecks, $restriction->getChecks()); |
|
313 | } |
|
314 | ||
315 | /** |
|
316 | * Test the correct detection a totalDigits- and fractionDigits-restriction. |
|
@@ 360-390 (lines=31) @@ | ||
357 | /** |
|
358 | * Test the correct detection a whiteSpace-restriction. |
|
359 | */ |
|
360 | public function testRestriction_10() |
|
361 | { |
|
362 | $schema = $this->reader->readString( |
|
363 | ' |
|
364 | <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|
365 | ||
366 | <xs:element name="whiteSpace"> |
|
367 | <xs:simpleType> |
|
368 | <xs:restriction base="xs:string"> |
|
369 | <xs:whiteSpace value="replace"/> |
|
370 | </xs:restriction> |
|
371 | </xs:simpleType> |
|
372 | </xs:element> |
|
373 | ||
374 | </xs:schema>'); |
|
375 | ||
376 | $element = $schema->findElement('whiteSpace', 'http://www.example.com'); |
|
377 | $simpleType = $element->getType(); |
|
378 | $restriction = $simpleType->getRestriction(); |
|
379 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Inheritance\Restriction', $restriction); |
|
380 | ||
381 | $expectedChecks = array( |
|
382 | 'whiteSpace' => array( |
|
383 | array( |
|
384 | 'value' => 'replace', |
|
385 | 'doc' => '', |
|
386 | ), |
|
387 | ), |
|
388 | ); |
|
389 | $this->assertEquals($expectedChecks, $restriction->getChecks()); |
|
390 | } |
|
391 | } |
|
392 |