Skip to content

Commit

Permalink
Merge pull request #2 from goetas-webservices/schema-deps
Browse files Browse the repository at this point in the history
Allow cross schema imports
  • Loading branch information
goetas authored Jan 18, 2018
2 parents 7ca3121 + 06bd60e commit 806c34c
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 20 deletions.
20 changes: 11 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@ language: php
sudo: false

php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- 7.1
- 7.2

matrix:
include:
- php: 7.1
env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable'

cache:
directories:
- vendor
- $HOME/.composer/cache

before_script:
- if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then echo "xdebug.max_nesting_level=1000" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
- if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then PHPUNIT_FLAGS="--coverage-clover=coverage.clover"; else PHPUNIT_FLAGS=""; fi
- if [[ $TRAVIS_PHP_VERSION != '5.6' && $TRAVIS_PHP_VERSION != 'hhvm' ]]; then phpenv config-rm xdebug.ini; fi
- if [[ $TRAVIS_PHP_VERSION = '7.1' ]]; then echo "xdebug.max_nesting_level=1000" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
- if [[ $TRAVIS_PHP_VERSION = '7.1' ]]; then PHPUNIT_FLAGS="--coverage-clover=coverage.clover"; else PHPUNIT_FLAGS=""; fi
- if [[ $TRAVIS_PHP_VERSION != '7.1' ]]; then phpenv config-rm xdebug.ini; fi
- travis_retry composer self-update
- travis_retry composer update $COMPOSER_FLAGS

script: vendor/bin/phpunit $PHPUNIT_FLAGS

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- if [[ $TRAVIS_PHP_VERSION = '5.6' ]] ; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
- if [[ $TRAVIS_PHP_VERSION = '7.1' ]] ; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
}
],
"require": {
"php": "^5.4|^7.0",
"goetas-webservices/xsd-reader": "^0.2",
"php": "^7.1",
"goetas-webservices/xsd-reader": "^0.3@dev",
"symfony/event-dispatcher" : "^2.4||^3.0"
},
"require-dev" : {
Expand Down
11 changes: 3 additions & 8 deletions src/DefinitionsReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,8 @@ function () use ($functions, $definitions, $node) {

private function loadTypes(Definitions $definitions, \DOMElement $node)
{
foreach ($node->childNodes as $k => $childNode) {
if (($childNode instanceof \DOMElement) && $childNode->namespaceURI === self::XSD_NS && $childNode->localName == 'schema') {

$schema = $this->reader->readNode($childNode, $childNode->ownerDocument->documentURI . "#" . $k);
$definitions->getSchema()->addSchema($schema);
}
}
$schema = $this->reader->readNodes(iterator_to_array($node->childNodes), $node->ownerDocument->documentURI);
$definitions->getSchema()->addSchema($schema);
}

private function loadBinding(Definitions $definitions, DOMElement $node)
Expand Down Expand Up @@ -518,4 +513,4 @@ private function getDOM($file)
}
return $xml;
}
}
}
15 changes: 14 additions & 1 deletion tests/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

use GoetasWebservices\XML\WSDLReader\DefinitionsReader;
use GoetasWebservices\XML\WSDLReader\Wsdl\Definitions;
use GoetasWebservices\XML\XSDReader\Schema\Element\ElementDef;
use GoetasWebservices\XML\XSDReader\Schema\Type\ComplexType;

class BaseTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -26,6 +28,17 @@ public function testReadFile()
$this->makeAssertionsLoad($definitions);
}

public function testReadCrossReferenceDefinitions()
{
$definitions = $this->reader->readFile(__DIR__ . '/resources/multi-schema-cross-reference.wsdl');

$details = $definitions->getSchema()->findType("outerType", "http://tempuri.org/1");
$this->assertInstanceOf(ComplexType::class, $details);

$details = $definitions->getSchema()->findElement("outerEl", "http://tempuri.org/1");
$this->assertInstanceOf(ElementDef::class, $details);
}

public function testReadString()
{
$definitions = $this->reader->readString(file_get_contents(__DIR__ . '/resources/base-wsdl.wsdl'));
Expand Down Expand Up @@ -198,4 +211,4 @@ protected function makeAssertionsLoad(Definitions $definitions)


}
}
}
22 changes: 22 additions & 0 deletions tests/resources/multi-schema-cross-reference.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://tempuri.org/0">
<wsdl:types>
<xs:schema targetNamespace="http://tempuri.org/1" xmlns:t2="http://tempuri.org/2">
<xs:import namespace="http://tempuri.org/2"/>
<xs:element name="outerEl" type="t2:inner"/>
<xs:complexType name="outerType">
<xs:attribute type="t2:innerAttrType" name="att"/>
</xs:complexType>
</xs:schema>
<xs:schema targetNamespace="http://tempuri.org/2">
<xs:complexType name="inner">
<xs:attribute name="inner_attr"/>
</xs:complexType>
<xs:simpleType name="innerAttrType">
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:schema>
</wsdl:types>
</wsdl:definitions>

0 comments on commit 806c34c

Please sign in to comment.