Code Duplication    Length = 33-34 lines in 2 locations

tests/AttributesTest.php 1 location

@@ 60-92 (lines=33) @@
57
58
    }
59
60
    public function testAnonym()
61
    {
62
        $schema = $this->reader->readString(
63
            '
64
            <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
65
66
                <xs:attribute name="myAttributeAnonType">
67
                    <xs:simpleType>
68
                        <xs:restriction base="xs:string"></xs:restriction>
69
                    </xs:simpleType>
70
                </xs:attribute>
71
72
            </xs:schema>');
73
74
75
        $myAttributeAnon = $schema->findAttribute('myAttributeAnonType', 'http://www.example.com');
76
        $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Attribute\AttributeDef', $myAttributeAnon);
77
        //$this->assertEquals('http://www.example.com', $myAttribute->getSchema()->getTargetNamespace());
78
        $this->assertEquals('myAttributeAnonType', $myAttributeAnon->getName());
79
        $this->assertNull($myAttributeAnon->getType()->getName());
80
81
        $base2 = $myAttributeAnon->getType();
82
        $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType', $base2);
83
        $this->assertEquals('http://www.example.com', $base2->getSchema()->getTargetNamespace());
84
        $this->assertTrue(!$base2->getName());
85
86
87
        $restriction1 = $base2->getRestriction();
88
        $base3 = $restriction1->getBase();
89
        $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType', $base3);
90
        $this->assertEquals('http://www.w3.org/2001/XMLSchema', $base3->getSchema()->getTargetNamespace());
91
        $this->assertEquals('string', $base3->getName());
92
    }
93
}
94

tests/ElementsTest.php 1 location

@@ 51-84 (lines=34) @@
48
        $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Element\Group', $elementsInGroup[2]);
49
    }
50
51
    public function testAnonym()
52
    {
53
        $schema = $this->reader->readString(
54
            '
55
            <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
56
                <xs:element name="myElement" type="xs:string"></xs:element>
57
58
                <xs:element name="myElementAnonType">
59
                    <xs:simpleType>
60
                        <xs:restriction base="xs:string"></xs:restriction>
61
                    </xs:simpleType>
62
                </xs:element>
63
64
            </xs:schema>');
65
66
67
        $myElementAnon = $schema->findElement('myElementAnonType', 'http://www.example.com');
68
        $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Element\ElementDef', $myElementAnon);
69
        //$this->assertEquals('http://www.example.com', $myElement->getSchema()->getTargetNamespace());
70
        $this->assertEquals('myElementAnonType', $myElementAnon->getName());
71
        $this->assertNull($myElementAnon->getType()->getName());
72
73
        $base2 = $myElementAnon->getType();
74
        $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType', $base2);
75
        $this->assertEquals('http://www.example.com', $base2->getSchema()->getTargetNamespace());
76
        $this->assertTrue(!$base2->getName());
77
78
79
        $restriction1 = $base2->getRestriction();
80
        $base3 = $restriction1->getBase();
81
        $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType', $base3);
82
        $this->assertEquals('http://www.w3.org/2001/XMLSchema', $base3->getSchema()->getTargetNamespace());
83
        $this->assertEquals('string', $base3->getName());
84
    }
85
86
}
87