Passed
Push — static-analysis ( 536d5c...894217 )
by SignpostMarv
03:17
created

ImportTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 35
rs 10
c 0
b 0
f 0
1
<?php
2
namespace GoetasWebservices\XML\XSDReader\Tests;
3
4
class ImportTest extends BaseTest
5
{
6
7
8
    public function testBase()
9
    {
10
        $remoteSchema = $this->reader->readString(
11
            '
12
            <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
13
                <xs:attribute name="myAttribute" type="xs:string"></xs:attribute>
14
            </xs:schema>', 'http://www.example.com/xsd.xsd');
15
16
17
        $schema = $this->reader->readString(
18
            '
19
            <xs:schema targetNamespace="http://www.user.com" xmlns:xs="http://www.w3.org/2001/XMLSchema"  xmlns:ex="http://www.example.com">
20
                <xs:import schemaLocation="http://www.example.com/xsd.xsd" namespace="http://www.example.com"></xs:import>
21
22
                <xs:attributeGroup name="myAttributeGroup">
23
                    <xs:attribute ref="ex:myAttribute"></xs:attribute>
24
                </xs:attributeGroup>
25
26
            </xs:schema>');
27
28
        $this->assertContains($remoteSchema, $schema->getSchemas(), false, true);
29
30
        $remoteAttr = $remoteSchema->findAttribute("myAttribute", "http://www.example.com");
31
        $localAttr = $schema->findAttribute("myAttribute", "http://www.example.com");
32
33
        $this->assertSame($remoteAttr, $localAttr);
34
35
        $localAttrGroup = $schema->findAttributeGroup("myAttributeGroup", "http://www.user.com");
36
        $localAttrs = $localAttrGroup->getAttributes();
37
38
        $this->assertSame($remoteAttr, $localAttrs[0]);
39
    }
40
}
41