Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
francisbesset committed Jul 25, 2013
1 parent 0d8fb5a commit b96d7f1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor/
composer.lock
phpunit.xml
Tests/Fixtures/build_include/
2 changes: 1 addition & 1 deletion Tests/Fixtures/wsdlinclude/wsdlinctest_absolute.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<wsdl:documentation>wsdlincludetest</wsdl:documentation>
<wsdl:include location="http://localhost:8000/wsdl_include.wsdl"/>
<wsdl:include location="http://%location%/wsdl_include.wsdl"/>
</wsdl:definitions>
2 changes: 1 addition & 1 deletion Tests/Fixtures/xsdinclude/xsdinctest_absolute.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<wsdl:documentation>xsdinctest</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://test.sample">
<xs:include schemaLocation="http://localhost:8000/type_include.xsd"/>
<xs:include schemaLocation="http://%location%/type_include.xsd"/>
</xs:schema>
</wsdl:types>
</wsdl:definitions>
40 changes: 34 additions & 6 deletions Tests/WsdlDownloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use BeSimple\SoapClient\WsdlDownloader;
use BeSimple\SoapCommon\Cache;
use BeSimple\SoapClient\Curl;
use Symfony\Component\Filesystem\Filesystem;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamWrapper;

Expand All @@ -24,6 +25,10 @@
*/
class WsdlDownloaderTest extends AbstractWebserverTest
{
static protected $filesystem;

static protected $fixturesPath;

/**
* @dataProvider provideDownload
*/
Expand All @@ -49,7 +54,7 @@ public function provideDownload()
{
return array(
array(
__DIR__.DIRECTORY_SEPARATOR.'Fixtures/xsdinclude/xsdinctest_absolute.xml',
__DIR__.DIRECTORY_SEPARATOR.'Fixtures/build_include/xsdinctest_absolute.xml',
'%s/wsdl_[a-f0-9]{32}\.cache',
2,
),
Expand All @@ -59,7 +64,7 @@ public function provideDownload()
1,
),
array(
sprintf('http://localhost:%d/xsdinclude/xsdinctest_absolute.xml', WEBSERVER_PORT),
sprintf('http://localhost:%d/build_include/xsdinctest_absolute.xml', WEBSERVER_PORT),
'%s/wsdl_[a-f0-9]{32}\.cache',
2,
),
Expand Down Expand Up @@ -124,12 +129,12 @@ public function testResolveWsdlIncludes($source, $cacheFile, $remoteParentUrl, $

public function provideResolveWsdlIncludes()
{
$remoteUrlAbsolute = sprintf('http://localhost:%d/wsdlinclude/wsdlinctest_absolute.xml', WEBSERVER_PORT);
$remoteUrlAbsolute = sprintf('http://localhost:%d/build_include/wsdlinctest_absolute.xml', WEBSERVER_PORT);
$remoteUrlRelative = sprintf('http://localhost:%d/wsdlinclude/wsdlinctest_relative.xml', WEBSERVER_PORT);

return array(
array(
__DIR__.DIRECTORY_SEPARATOR.'Fixtures/wsdlinclude/wsdlinctest_absolute.xml',
__DIR__.DIRECTORY_SEPARATOR.'Fixtures/build_include/wsdlinctest_absolute.xml',
'%s/cache_local_absolute.xml',
null,
'%s/wsdl_[a-f0-9]{32}.cache',
Expand Down Expand Up @@ -187,12 +192,12 @@ public function testResolveXsdIncludes($source, $cacheFile, $remoteParentUrl, $r

public function provideResolveXsdIncludes()
{
$remoteUrlAbsolute = sprintf('http://localhost:%d/xsdinclude/xsdinctest_absolute.xml', WEBSERVER_PORT);
$remoteUrlAbsolute = sprintf('http://localhost:%d/build_include/xsdinctest_absolute.xml', WEBSERVER_PORT);
$remoteUrlRelative = sprintf('http://localhost:%d/xsdinclude/xsdinctest_relative.xml', WEBSERVER_PORT);

return array(
array(
__DIR__.DIRECTORY_SEPARATOR.'Fixtures/xsdinclude/xsdinctest_absolute.xml',
__DIR__.DIRECTORY_SEPARATOR.'Fixtures/build_include/xsdinctest_absolute.xml',
'%s/cache_local_absolute.xml',
null,
'%s/wsdl_[a-f0-9]{32}\.cache',
Expand Down Expand Up @@ -254,4 +259,27 @@ public function testResolveRelativePathInUrl()
$this->assertEquals('http://localhost/test', $m->invoke($wsdlDownloader, 'http://localhost/sub/sub/sub', '../../../test'));
$this->assertEquals('http://localhost/test', $m->invoke($wsdlDownloader, 'http://localhost/sub/sub/sub/', '../../../test'));
}

public static function setUpBeforeClass()
{
parent::setUpBeforeClass();

self::$filesystem = new Filesystem();
self::$fixturesPath = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR;
self::$filesystem->mkdir(self::$fixturesPath.'build_include');

foreach (array('wsdlinclude/wsdlinctest_absolute.xml', 'xsdinclude/xsdinctest_absolute.xml') as $file) {
$content = file_get_contents(self::$fixturesPath.$file);
$content = preg_replace('#'.preg_quote('%location%').'#', sprintf('localhost:%d', WEBSERVER_PORT), $content);

self::$filesystem->dumpFile(self::$fixturesPath.'build_include'.DIRECTORY_SEPARATOR.pathinfo($file, PATHINFO_BASENAME), $content);
}
}

public static function tearDownAfterClass()
{
parent::tearDownAfterClass();

self::$filesystem->remove(self::$fixturesPath.'build_include');
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"require-dev": {
"mikey179/vfsStream": "dev-master",
"symfony/filesystem": ">=2.3,<2.4-dev",
"symfony/process": ">=2.3,<2.4-dev"
},
"autoload": {
Expand Down

0 comments on commit b96d7f1

Please sign in to comment.