From b96d7f110e17c54161eb99a48038e8d0d44cfe5c Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Thu, 25 Jul 2013 09:29:22 +0200 Subject: [PATCH] Fixed tests --- .gitignore | 1 + .../wsdlinclude/wsdlinctest_absolute.xml | 2 +- .../xsdinclude/xsdinctest_absolute.xml | 2 +- Tests/WsdlDownloaderTest.php | 40 ++++++++++++++++--- composer.json | 1 + 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index c49a5d8..db0e5ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ vendor/ composer.lock phpunit.xml +Tests/Fixtures/build_include/ diff --git a/Tests/Fixtures/wsdlinclude/wsdlinctest_absolute.xml b/Tests/Fixtures/wsdlinclude/wsdlinctest_absolute.xml index dae033e..2f59ba1 100644 --- a/Tests/Fixtures/wsdlinclude/wsdlinctest_absolute.xml +++ b/Tests/Fixtures/wsdlinclude/wsdlinctest_absolute.xml @@ -1,5 +1,5 @@ wsdlincludetest - + diff --git a/Tests/Fixtures/xsdinclude/xsdinctest_absolute.xml b/Tests/Fixtures/xsdinclude/xsdinctest_absolute.xml index dc1b373..166e549 100644 --- a/Tests/Fixtures/xsdinclude/xsdinctest_absolute.xml +++ b/Tests/Fixtures/xsdinclude/xsdinctest_absolute.xml @@ -3,7 +3,7 @@ xsdinctest - + diff --git a/Tests/WsdlDownloaderTest.php b/Tests/WsdlDownloaderTest.php index f42e2e7..27f419e 100644 --- a/Tests/WsdlDownloaderTest.php +++ b/Tests/WsdlDownloaderTest.php @@ -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; @@ -24,6 +25,10 @@ */ class WsdlDownloaderTest extends AbstractWebserverTest { + static protected $filesystem; + + static protected $fixturesPath; + /** * @dataProvider provideDownload */ @@ -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, ), @@ -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, ), @@ -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', @@ -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', @@ -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'); + } } diff --git a/composer.json b/composer.json index 352d888..3df0b70 100644 --- a/composer.json +++ b/composer.json @@ -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": {