From 66c679c1c97add78e46c67a0415a58fc0d1a19c9 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Fri, 19 Jul 2013 11:28:23 +0200 Subject: [PATCH 1/7] Reorganized directories structure --- .gitignore | 8 ++-- src/BeSimple/SoapClient/Curl.php => Curl.php | 0 .../MimeFilter.php => MimeFilter.php | 0 .../SoapClient.php => SoapClient.php | 0 ...ClientBuilder.php => SoapClientBuilder.php | 0 .../SoapKernel.php => SoapKernel.php | 0 .../SoapRequest.php => SoapRequest.php | 0 .../SoapResponse.php => SoapResponse.php | 0 {tests => Tests}/AxisInterop/MTOM.php | 0 {tests => Tests}/AxisInterop/MTOM.wsdl | 0 {tests => Tests}/AxisInterop/SwA.php | 0 {tests => Tests}/AxisInterop/SwA.wsdl | 0 {tests => Tests}/AxisInterop/SwA/build.xml | 0 .../SwA/resources/META-INF/services.xml | 0 .../besimple/service/BeSimpleSwaService.java | 0 {tests => Tests}/AxisInterop/WsAddressing.php | 0 .../AxisInterop/WsSecuritySigEnc.php | 0 .../AxisInterop/WsSecuritySigEnc.wsdl | 0 .../AxisInterop/WsSecurityUserPass.php | 0 .../AxisInterop/WsSecurityUserPass.wsdl | 0 .../axis_services/besimple-swa.aar | Bin .../axis_services/library-signencr.aar | Bin .../axis_services/library-username-digest.aar | Bin .../AxisInterop/axis_services/sample-mtom.aar | Bin .../AxisInterop/axis_services/version2.aar | Bin {tests => Tests}/AxisInterop/clientcert.pem | 0 {tests => Tests}/AxisInterop/clientkey.pem | 0 {tests => Tests}/AxisInterop/image.jpg | Bin {tests => Tests}/AxisInterop/servercert.pem | 0 .../Tests/SoapClient => Tests}/CurlTest.php | 8 ++-- .../SoapClient => Tests}/Fixtures/curl.txt | 0 .../SoapClient => Tests}/Fixtures/foobar.wsdl | 0 .../Fixtures/type_include.xsd | 0 .../Fixtures/wsdl_include.wsdl | 0 .../wsdlinclude/wsdlinctest_absolute.xml | 0 .../wsdlinclude/wsdlinctest_relative.xml | 0 .../xsdinclude/xsdinctest_absolute.xml | 0 .../xsdinclude/xsdinctest_relative.xml | 0 {tests => Tests}/ServerInterop/MTOM.php | 0 {tests => Tests}/ServerInterop/MTOM.wsdl | 0 {tests => Tests}/ServerInterop/MTOMServer.php | 0 .../SoapClientBuilderTest.php | 4 +- .../WsdlDownloaderTest.php | 6 ++- ...essingFilter.php => WsAddressingFilter.php | 0 ...SecurityFilter.php => WsSecurityFilter.php | 0 .../WsdlDownloader.php => WsdlDownloader.php | 0 .../XmlMimeFilter.php => XmlMimeFilter.php | 0 composer.json | 9 ++-- phpunit.xml.dist | 18 ++++---- tests/bootstrap.php | 36 --------------- vendors.php | 42 ------------------ 51 files changed, 27 insertions(+), 104 deletions(-) rename src/BeSimple/SoapClient/Curl.php => Curl.php (100%) rename src/BeSimple/SoapClient/MimeFilter.php => MimeFilter.php (100%) rename src/BeSimple/SoapClient/SoapClient.php => SoapClient.php (100%) rename src/BeSimple/SoapClient/SoapClientBuilder.php => SoapClientBuilder.php (100%) rename src/BeSimple/SoapClient/SoapKernel.php => SoapKernel.php (100%) rename src/BeSimple/SoapClient/SoapRequest.php => SoapRequest.php (100%) rename src/BeSimple/SoapClient/SoapResponse.php => SoapResponse.php (100%) rename {tests => Tests}/AxisInterop/MTOM.php (100%) rename {tests => Tests}/AxisInterop/MTOM.wsdl (100%) rename {tests => Tests}/AxisInterop/SwA.php (100%) rename {tests => Tests}/AxisInterop/SwA.wsdl (100%) rename {tests => Tests}/AxisInterop/SwA/build.xml (100%) rename {tests => Tests}/AxisInterop/SwA/resources/META-INF/services.xml (100%) rename {tests => Tests}/AxisInterop/SwA/src/besimple/service/BeSimpleSwaService.java (100%) rename {tests => Tests}/AxisInterop/WsAddressing.php (100%) rename {tests => Tests}/AxisInterop/WsSecuritySigEnc.php (100%) rename {tests => Tests}/AxisInterop/WsSecuritySigEnc.wsdl (100%) rename {tests => Tests}/AxisInterop/WsSecurityUserPass.php (100%) rename {tests => Tests}/AxisInterop/WsSecurityUserPass.wsdl (100%) rename {tests => Tests}/AxisInterop/axis_services/besimple-swa.aar (100%) rename {tests => Tests}/AxisInterop/axis_services/library-signencr.aar (100%) rename {tests => Tests}/AxisInterop/axis_services/library-username-digest.aar (100%) rename {tests => Tests}/AxisInterop/axis_services/sample-mtom.aar (100%) rename {tests => Tests}/AxisInterop/axis_services/version2.aar (100%) rename {tests => Tests}/AxisInterop/clientcert.pem (100%) rename {tests => Tests}/AxisInterop/clientkey.pem (100%) rename {tests => Tests}/AxisInterop/image.jpg (100%) rename {tests => Tests}/AxisInterop/servercert.pem (100%) rename {tests/BeSimple/Tests/SoapClient => Tests}/CurlTest.php (96%) rename {tests/BeSimple/Tests/SoapClient => Tests}/Fixtures/curl.txt (100%) rename {tests/BeSimple/Tests/SoapClient => Tests}/Fixtures/foobar.wsdl (100%) rename {tests/BeSimple/Tests/SoapClient => Tests}/Fixtures/type_include.xsd (100%) rename {tests/BeSimple/Tests/SoapClient => Tests}/Fixtures/wsdl_include.wsdl (100%) rename {tests/BeSimple/Tests/SoapClient => Tests}/Fixtures/wsdlinclude/wsdlinctest_absolute.xml (100%) rename {tests/BeSimple/Tests/SoapClient => Tests}/Fixtures/wsdlinclude/wsdlinctest_relative.xml (100%) rename {tests/BeSimple/Tests/SoapClient => Tests}/Fixtures/xsdinclude/xsdinctest_absolute.xml (100%) rename {tests/BeSimple/Tests/SoapClient => Tests}/Fixtures/xsdinclude/xsdinctest_relative.xml (100%) rename {tests => Tests}/ServerInterop/MTOM.php (100%) rename {tests => Tests}/ServerInterop/MTOM.wsdl (100%) rename {tests => Tests}/ServerInterop/MTOMServer.php (100%) rename {tests/BeSimple/Tests/SoapClient => Tests}/SoapClientBuilderTest.php (99%) rename {tests/BeSimple/Tests/SoapClient => Tests}/WsdlDownloaderTest.php (98%) rename src/BeSimple/SoapClient/WsAddressingFilter.php => WsAddressingFilter.php (100%) rename src/BeSimple/SoapClient/WsSecurityFilter.php => WsSecurityFilter.php (100%) rename src/BeSimple/SoapClient/WsdlDownloader.php => WsdlDownloader.php (100%) rename src/BeSimple/SoapClient/XmlMimeFilter.php => XmlMimeFilter.php (100%) delete mode 100644 tests/bootstrap.php delete mode 100644 vendors.php diff --git a/.gitignore b/.gitignore index f8d178e..c49a5d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -vendor -/phpunit.xml -.buildpath -.project -.settings \ No newline at end of file +vendor/ +composer.lock +phpunit.xml diff --git a/src/BeSimple/SoapClient/Curl.php b/Curl.php similarity index 100% rename from src/BeSimple/SoapClient/Curl.php rename to Curl.php diff --git a/src/BeSimple/SoapClient/MimeFilter.php b/MimeFilter.php similarity index 100% rename from src/BeSimple/SoapClient/MimeFilter.php rename to MimeFilter.php diff --git a/src/BeSimple/SoapClient/SoapClient.php b/SoapClient.php similarity index 100% rename from src/BeSimple/SoapClient/SoapClient.php rename to SoapClient.php diff --git a/src/BeSimple/SoapClient/SoapClientBuilder.php b/SoapClientBuilder.php similarity index 100% rename from src/BeSimple/SoapClient/SoapClientBuilder.php rename to SoapClientBuilder.php diff --git a/src/BeSimple/SoapClient/SoapKernel.php b/SoapKernel.php similarity index 100% rename from src/BeSimple/SoapClient/SoapKernel.php rename to SoapKernel.php diff --git a/src/BeSimple/SoapClient/SoapRequest.php b/SoapRequest.php similarity index 100% rename from src/BeSimple/SoapClient/SoapRequest.php rename to SoapRequest.php diff --git a/src/BeSimple/SoapClient/SoapResponse.php b/SoapResponse.php similarity index 100% rename from src/BeSimple/SoapClient/SoapResponse.php rename to SoapResponse.php diff --git a/tests/AxisInterop/MTOM.php b/Tests/AxisInterop/MTOM.php similarity index 100% rename from tests/AxisInterop/MTOM.php rename to Tests/AxisInterop/MTOM.php diff --git a/tests/AxisInterop/MTOM.wsdl b/Tests/AxisInterop/MTOM.wsdl similarity index 100% rename from tests/AxisInterop/MTOM.wsdl rename to Tests/AxisInterop/MTOM.wsdl diff --git a/tests/AxisInterop/SwA.php b/Tests/AxisInterop/SwA.php similarity index 100% rename from tests/AxisInterop/SwA.php rename to Tests/AxisInterop/SwA.php diff --git a/tests/AxisInterop/SwA.wsdl b/Tests/AxisInterop/SwA.wsdl similarity index 100% rename from tests/AxisInterop/SwA.wsdl rename to Tests/AxisInterop/SwA.wsdl diff --git a/tests/AxisInterop/SwA/build.xml b/Tests/AxisInterop/SwA/build.xml similarity index 100% rename from tests/AxisInterop/SwA/build.xml rename to Tests/AxisInterop/SwA/build.xml diff --git a/tests/AxisInterop/SwA/resources/META-INF/services.xml b/Tests/AxisInterop/SwA/resources/META-INF/services.xml similarity index 100% rename from tests/AxisInterop/SwA/resources/META-INF/services.xml rename to Tests/AxisInterop/SwA/resources/META-INF/services.xml diff --git a/tests/AxisInterop/SwA/src/besimple/service/BeSimpleSwaService.java b/Tests/AxisInterop/SwA/src/besimple/service/BeSimpleSwaService.java similarity index 100% rename from tests/AxisInterop/SwA/src/besimple/service/BeSimpleSwaService.java rename to Tests/AxisInterop/SwA/src/besimple/service/BeSimpleSwaService.java diff --git a/tests/AxisInterop/WsAddressing.php b/Tests/AxisInterop/WsAddressing.php similarity index 100% rename from tests/AxisInterop/WsAddressing.php rename to Tests/AxisInterop/WsAddressing.php diff --git a/tests/AxisInterop/WsSecuritySigEnc.php b/Tests/AxisInterop/WsSecuritySigEnc.php similarity index 100% rename from tests/AxisInterop/WsSecuritySigEnc.php rename to Tests/AxisInterop/WsSecuritySigEnc.php diff --git a/tests/AxisInterop/WsSecuritySigEnc.wsdl b/Tests/AxisInterop/WsSecuritySigEnc.wsdl similarity index 100% rename from tests/AxisInterop/WsSecuritySigEnc.wsdl rename to Tests/AxisInterop/WsSecuritySigEnc.wsdl diff --git a/tests/AxisInterop/WsSecurityUserPass.php b/Tests/AxisInterop/WsSecurityUserPass.php similarity index 100% rename from tests/AxisInterop/WsSecurityUserPass.php rename to Tests/AxisInterop/WsSecurityUserPass.php diff --git a/tests/AxisInterop/WsSecurityUserPass.wsdl b/Tests/AxisInterop/WsSecurityUserPass.wsdl similarity index 100% rename from tests/AxisInterop/WsSecurityUserPass.wsdl rename to Tests/AxisInterop/WsSecurityUserPass.wsdl diff --git a/tests/AxisInterop/axis_services/besimple-swa.aar b/Tests/AxisInterop/axis_services/besimple-swa.aar similarity index 100% rename from tests/AxisInterop/axis_services/besimple-swa.aar rename to Tests/AxisInterop/axis_services/besimple-swa.aar diff --git a/tests/AxisInterop/axis_services/library-signencr.aar b/Tests/AxisInterop/axis_services/library-signencr.aar similarity index 100% rename from tests/AxisInterop/axis_services/library-signencr.aar rename to Tests/AxisInterop/axis_services/library-signencr.aar diff --git a/tests/AxisInterop/axis_services/library-username-digest.aar b/Tests/AxisInterop/axis_services/library-username-digest.aar similarity index 100% rename from tests/AxisInterop/axis_services/library-username-digest.aar rename to Tests/AxisInterop/axis_services/library-username-digest.aar diff --git a/tests/AxisInterop/axis_services/sample-mtom.aar b/Tests/AxisInterop/axis_services/sample-mtom.aar similarity index 100% rename from tests/AxisInterop/axis_services/sample-mtom.aar rename to Tests/AxisInterop/axis_services/sample-mtom.aar diff --git a/tests/AxisInterop/axis_services/version2.aar b/Tests/AxisInterop/axis_services/version2.aar similarity index 100% rename from tests/AxisInterop/axis_services/version2.aar rename to Tests/AxisInterop/axis_services/version2.aar diff --git a/tests/AxisInterop/clientcert.pem b/Tests/AxisInterop/clientcert.pem similarity index 100% rename from tests/AxisInterop/clientcert.pem rename to Tests/AxisInterop/clientcert.pem diff --git a/tests/AxisInterop/clientkey.pem b/Tests/AxisInterop/clientkey.pem similarity index 100% rename from tests/AxisInterop/clientkey.pem rename to Tests/AxisInterop/clientkey.pem diff --git a/tests/AxisInterop/image.jpg b/Tests/AxisInterop/image.jpg similarity index 100% rename from tests/AxisInterop/image.jpg rename to Tests/AxisInterop/image.jpg diff --git a/tests/AxisInterop/servercert.pem b/Tests/AxisInterop/servercert.pem similarity index 100% rename from tests/AxisInterop/servercert.pem rename to Tests/AxisInterop/servercert.pem diff --git a/tests/BeSimple/Tests/SoapClient/CurlTest.php b/Tests/CurlTest.php similarity index 96% rename from tests/BeSimple/Tests/SoapClient/CurlTest.php rename to Tests/CurlTest.php index d669f4c..f8fc24b 100644 --- a/tests/BeSimple/Tests/SoapClient/CurlTest.php +++ b/Tests/CurlTest.php @@ -10,7 +10,7 @@ * with this source code in the file LICENSE. */ -namespace BeSimple\SoapClient; +namespace BeSimple\SoapClient\Tests; use BeSimple\SoapClient\Curl; @@ -23,7 +23,9 @@ class CurlTest extends \PHPUnit_Framework_TestCase protected function startPhpWebserver() { - $dir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'; + $this->markTestSkipped('Start a local webserver is not the best practice'); + + $dir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'; if ('Windows' == substr(php_uname('s'), 0, 7)) { $powershellCommand = "\$app = start-process php.exe -ArgumentList '-S localhost:8000 -t ".$dir."' -WindowStyle 'Hidden' -passthru; Echo \$app.Id;"; $shellCommand = 'powershell -command "& {'.$powershellCommand.'}"'; @@ -178,4 +180,4 @@ public function testGetResponseStatusMessage() $this->stopPhpWebserver(); } -} \ No newline at end of file +} diff --git a/tests/BeSimple/Tests/SoapClient/Fixtures/curl.txt b/Tests/Fixtures/curl.txt similarity index 100% rename from tests/BeSimple/Tests/SoapClient/Fixtures/curl.txt rename to Tests/Fixtures/curl.txt diff --git a/tests/BeSimple/Tests/SoapClient/Fixtures/foobar.wsdl b/Tests/Fixtures/foobar.wsdl similarity index 100% rename from tests/BeSimple/Tests/SoapClient/Fixtures/foobar.wsdl rename to Tests/Fixtures/foobar.wsdl diff --git a/tests/BeSimple/Tests/SoapClient/Fixtures/type_include.xsd b/Tests/Fixtures/type_include.xsd similarity index 100% rename from tests/BeSimple/Tests/SoapClient/Fixtures/type_include.xsd rename to Tests/Fixtures/type_include.xsd diff --git a/tests/BeSimple/Tests/SoapClient/Fixtures/wsdl_include.wsdl b/Tests/Fixtures/wsdl_include.wsdl similarity index 100% rename from tests/BeSimple/Tests/SoapClient/Fixtures/wsdl_include.wsdl rename to Tests/Fixtures/wsdl_include.wsdl diff --git a/tests/BeSimple/Tests/SoapClient/Fixtures/wsdlinclude/wsdlinctest_absolute.xml b/Tests/Fixtures/wsdlinclude/wsdlinctest_absolute.xml similarity index 100% rename from tests/BeSimple/Tests/SoapClient/Fixtures/wsdlinclude/wsdlinctest_absolute.xml rename to Tests/Fixtures/wsdlinclude/wsdlinctest_absolute.xml diff --git a/tests/BeSimple/Tests/SoapClient/Fixtures/wsdlinclude/wsdlinctest_relative.xml b/Tests/Fixtures/wsdlinclude/wsdlinctest_relative.xml similarity index 100% rename from tests/BeSimple/Tests/SoapClient/Fixtures/wsdlinclude/wsdlinctest_relative.xml rename to Tests/Fixtures/wsdlinclude/wsdlinctest_relative.xml diff --git a/tests/BeSimple/Tests/SoapClient/Fixtures/xsdinclude/xsdinctest_absolute.xml b/Tests/Fixtures/xsdinclude/xsdinctest_absolute.xml similarity index 100% rename from tests/BeSimple/Tests/SoapClient/Fixtures/xsdinclude/xsdinctest_absolute.xml rename to Tests/Fixtures/xsdinclude/xsdinctest_absolute.xml diff --git a/tests/BeSimple/Tests/SoapClient/Fixtures/xsdinclude/xsdinctest_relative.xml b/Tests/Fixtures/xsdinclude/xsdinctest_relative.xml similarity index 100% rename from tests/BeSimple/Tests/SoapClient/Fixtures/xsdinclude/xsdinctest_relative.xml rename to Tests/Fixtures/xsdinclude/xsdinctest_relative.xml diff --git a/tests/ServerInterop/MTOM.php b/Tests/ServerInterop/MTOM.php similarity index 100% rename from tests/ServerInterop/MTOM.php rename to Tests/ServerInterop/MTOM.php diff --git a/tests/ServerInterop/MTOM.wsdl b/Tests/ServerInterop/MTOM.wsdl similarity index 100% rename from tests/ServerInterop/MTOM.wsdl rename to Tests/ServerInterop/MTOM.wsdl diff --git a/tests/ServerInterop/MTOMServer.php b/Tests/ServerInterop/MTOMServer.php similarity index 100% rename from tests/ServerInterop/MTOMServer.php rename to Tests/ServerInterop/MTOMServer.php diff --git a/tests/BeSimple/Tests/SoapClient/SoapClientBuilderTest.php b/Tests/SoapClientBuilderTest.php similarity index 99% rename from tests/BeSimple/Tests/SoapClient/SoapClientBuilderTest.php rename to Tests/SoapClientBuilderTest.php index 9b33cce..a0ebfeb 100644 --- a/tests/BeSimple/Tests/SoapClient/SoapClientBuilderTest.php +++ b/Tests/SoapClientBuilderTest.php @@ -10,7 +10,7 @@ * with this source code in the file LICENSE. */ -namespace BeSimple\Tests\SoapCommon\Soap; +namespace BeSimple\SoapClient\Tests; use BeSimple\SoapClient\SoapClientBuilder; @@ -116,4 +116,4 @@ private function mergeOptions(array $options) { return array_merge($this->defaultOptions, $options); } -} \ No newline at end of file +} diff --git a/tests/BeSimple/Tests/SoapClient/WsdlDownloaderTest.php b/Tests/WsdlDownloaderTest.php similarity index 98% rename from tests/BeSimple/Tests/SoapClient/WsdlDownloaderTest.php rename to Tests/WsdlDownloaderTest.php index 198341d..8f3825f 100644 --- a/tests/BeSimple/Tests/SoapClient/WsdlDownloaderTest.php +++ b/Tests/WsdlDownloaderTest.php @@ -10,7 +10,7 @@ * with this source code in the file LICENSE. */ -namespace BeSimple\SoapClient; +namespace BeSimple\SoapClient\Tests; use BeSimple\SoapClient\WsdlDownloader; use BeSimple\SoapClient\Curl; @@ -24,6 +24,8 @@ class WsdlDownloaderTest extends \PHPUnit_Framework_TestCase protected function startPhpWebserver() { + $this->markTestSkipped('Start a local webserver is not the best practice'); + $dir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'; if ('Windows' == substr(php_uname('s'), 0, 7)) { $powershellCommand = "\$app = start-process php.exe -ArgumentList '-S localhost:8000 -t ".$dir."' -WindowStyle 'Hidden' -passthru; Echo \$app.Id;"; @@ -263,4 +265,4 @@ public function testResolveRelativePathInUrl() $this->assertEquals('http://localhost/test', $method->invoke($wd, 'http://localhost/sub/sub/sub', '../../../test')); $this->assertEquals('http://localhost/test', $method->invoke($wd, 'http://localhost/sub/sub/sub/', '../../../test')); } -} \ No newline at end of file +} diff --git a/src/BeSimple/SoapClient/WsAddressingFilter.php b/WsAddressingFilter.php similarity index 100% rename from src/BeSimple/SoapClient/WsAddressingFilter.php rename to WsAddressingFilter.php diff --git a/src/BeSimple/SoapClient/WsSecurityFilter.php b/WsSecurityFilter.php similarity index 100% rename from src/BeSimple/SoapClient/WsSecurityFilter.php rename to WsSecurityFilter.php diff --git a/src/BeSimple/SoapClient/WsdlDownloader.php b/WsdlDownloader.php similarity index 100% rename from src/BeSimple/SoapClient/WsdlDownloader.php rename to WsdlDownloader.php diff --git a/src/BeSimple/SoapClient/XmlMimeFilter.php b/XmlMimeFilter.php similarity index 100% rename from src/BeSimple/SoapClient/XmlMimeFilter.php rename to XmlMimeFilter.php diff --git a/composer.json b/composer.json index 0c5e927..cb4b31a 100644 --- a/composer.json +++ b/composer.json @@ -21,13 +21,14 @@ ], "require": { "php": ">=5.3.0", + "ext-soap": "*", + "ext-curl": "*", "besimple/soap-common": "dev-master", "ass/xmlsecurity": "dev-master" }, "autoload": { - "psr-0": { - "BeSimple\\SoapClient": "BeSimple/SoapClient/src/" - } + "psr-0": { "BeSimple\\SoapClient": "" } }, - "target-dir": "BeSimple/SoapClient" + "target-dir": "BeSimple/SoapClient", + "minimum-stability": "dev" } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4f8e547..13bd743 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -9,23 +9,21 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" - bootstrap="tests/bootstrap.php" + bootstrap="vendor/autoload.php" > - - ./tests/BeSimple/ + + ./Tests/ - - - benchmark - - - - ./src/BeSimple/ + ./ + + ./Tests/ + ./vendor/ + diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index d2872c6..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,36 +0,0 @@ - - * (c) Francis Besset - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -/* - -CAUTION: This file installs the dependencies needed to run the BeSimpleSoapClient test suite. - -https://github.com/BeSimple/BeSimpleSoapClient - -*/ - -if (!is_dir($vendorDir = dirname(__FILE__).'/vendor')) { - mkdir($vendorDir, 0777, true); -} - -$deps = array( - array('besimple-soapcommon', 'http://github.com/BeSimple/BeSimpleSoapCommon.git', 'origin/HEAD'), - array('XmlSecurity', 'https://github.com/aschamberger/XmlSecurity.git', 'origin/HEAD'), -); - -foreach ($deps as $dep) { - list($name, $url, $rev) = $dep; - - echo "> Installing/Updating $name\n"; - - $installDir = $vendorDir.'/'.$name; - if (!is_dir($installDir)) { - system(sprintf('git clone %s %s', escapeshellarg($url), escapeshellarg($installDir))); - } - - system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev))); -} From 510bbf329d8a56bc080192f4207afbc259c8de5c Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Fri, 19 Jul 2013 11:34:58 +0200 Subject: [PATCH 2/7] Created branch-alias 0.1-dev --- composer.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index cb4b31a..8cf7483 100644 --- a/composer.json +++ b/composer.json @@ -23,12 +23,17 @@ "php": ">=5.3.0", "ext-soap": "*", "ext-curl": "*", - "besimple/soap-common": "dev-master", + "besimple/soap-common": "self.version", "ass/xmlsecurity": "dev-master" }, "autoload": { "psr-0": { "BeSimple\\SoapClient": "" } }, "target-dir": "BeSimple/SoapClient", - "minimum-stability": "dev" + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "0.1-dev" + } + } } From 229c866b64cfc04db51036b02698e6cfc1f66cd6 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Wed, 24 Jul 2013 23:18:41 +0200 Subject: [PATCH 3/7] Fixed tests which require a webserver --- Tests/AbstractWebserverTest.php | 55 +++++ Tests/CurlTest.php | 120 ++-------- Tests/WsdlDownloaderTest.php | 387 ++++++++++++++++---------------- WsdlDownloader.php | 134 +++++------ composer.json | 4 + phpunit.xml.dist | 5 + 6 files changed, 344 insertions(+), 361 deletions(-) create mode 100644 Tests/AbstractWebserverTest.php diff --git a/Tests/AbstractWebserverTest.php b/Tests/AbstractWebserverTest.php new file mode 100644 index 0000000..54e5be4 --- /dev/null +++ b/Tests/AbstractWebserverTest.php @@ -0,0 +1,55 @@ + + * (c) Francis Besset + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapClient\Tests; + +use Symfony\Component\Process\PhpExecutableFinder; +use Symfony\Component\Process\ProcessBuilder; + +/** + * @author francis.besset@gmail.com + */ +abstract class AbstractWebServerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var ProcessBuilder + */ + static protected $webserver; + static protected $websererPortLength; + + public static function setUpBeforeClass() + { + if (version_compare(PHP_VERSION, '5.4.0', '<')) { + self::markTestSkipped('PHP Webserver is available from PHP 5.4'); + } + + self::$webserver = ProcessBuilder::create(array( + 'exec', // used exec binary (https://github.com/symfony/symfony/issues/5759) + (new PhpExecutableFinder())->find(), + '-S', + sprintf('localhost:%d', WEBSERVER_PORT), + '-t', + __DIR__.DIRECTORY_SEPARATOR.'Fixtures', + ))->getProcess(); + + self::$webserver->start(); + usleep(100000); + + self::$websererPortLength = strlen(WEBSERVER_PORT); + } + + public static function tearDownAfterClass() + { + self::$webserver->stop(0); + usleep(100000); + } +} diff --git a/Tests/CurlTest.php b/Tests/CurlTest.php index f8fc24b..a7e8541 100644 --- a/Tests/CurlTest.php +++ b/Tests/CurlTest.php @@ -17,167 +17,91 @@ /** * @author Andreas Schamberger */ -class CurlTest extends \PHPUnit_Framework_TestCase +class CurlTest extends AbstractWebserverTest { - protected $webserverProcessId; - - protected function startPhpWebserver() - { - $this->markTestSkipped('Start a local webserver is not the best practice'); - - $dir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'; - if ('Windows' == substr(php_uname('s'), 0, 7)) { - $powershellCommand = "\$app = start-process php.exe -ArgumentList '-S localhost:8000 -t ".$dir."' -WindowStyle 'Hidden' -passthru; Echo \$app.Id;"; - $shellCommand = 'powershell -command "& {'.$powershellCommand.'}"'; - } else { - $shellCommand = "nohup php -S localhost:8000 -t ".$dir." &"; - } - $output = array(); - exec($shellCommand, $output); - $this->webserverProcessId = $output[0]; // pid is in first element - } - - protected function stopPhpWebserver() - { - if (!is_null($this->webserverProcessId)) { - if ('Windows' == substr(php_uname('s'), 0, 7 )) { - exec('TASKKILL /F /PID ' . $this->webserverProcessId); - } else { - exec('kill ' . $this->webserverProcessId); - } - $this->webserverProcessId = null; - } - } - public function testExec() { - $this->startPhpWebserver(); - $curl = new Curl(); - $this->assertTrue($curl->exec('http://localhost:8000/curl.txt')); - $this->assertTrue($curl->exec('http://localhost:8000/404.txt')); - - $this->stopPhpWebserver(); + $this->assertTrue($curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT))); + $this->assertTrue($curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT))); } public function testGetErrorMessage() { - $this->startPhpWebserver(); - $curl = new Curl(); $curl->exec('http://unknown/curl.txt'); $this->assertEquals('Could not connect to host', $curl->getErrorMessage()); - $curl->exec('xyz://localhost:8000/@404.txt'); + $curl->exec(sprintf('xyz://localhost:%d/@404.txt', WEBSERVER_PORT)); $this->assertEquals('Unknown protocol. Only http and https are allowed.', $curl->getErrorMessage()); $curl->exec(''); $this->assertEquals('Unable to parse URL', $curl->getErrorMessage()); - - $this->stopPhpWebserver(); } public function testGetRequestHeaders() { - $this->startPhpWebserver(); - $curl = new Curl(); - $curl->exec('http://localhost:8000/curl.txt'); - $this->assertEquals(136, strlen($curl->getRequestHeaders())); + $curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)); + $this->assertEquals(132 + self::$websererPortLength, strlen($curl->getRequestHeaders())); - $curl->exec('http://localhost:8000/404.txt'); - $this->assertEquals(135, strlen($curl->getRequestHeaders())); - - $this->stopPhpWebserver(); + $curl->exec(sprintf('http://localhost:%s/404.txt', WEBSERVER_PORT)); + $this->assertEquals(131 + self::$websererPortLength, strlen($curl->getRequestHeaders())); } public function testGetResponse() { - $this->startPhpWebserver(); - $curl = new Curl(); - $curl->exec('http://localhost:8000/curl.txt'); - $this->assertEquals(150, strlen($curl->getResponse())); + $curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)); + $this->assertSame('OK', $curl->getResponseStatusMessage()); + $this->assertEquals(145 + self::$websererPortLength, strlen($curl->getResponse())); - $curl->exec('http://localhost:8000/404.txt'); - $this->assertEquals(1282, strlen($curl->getResponse())); - - $this->stopPhpWebserver(); + $curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT)); + $this->assertSame('Not Found', $curl->getResponseStatusMessage()); } public function testGetResponseBody() { - $this->startPhpWebserver(); - $curl = new Curl(); - $curl->exec('http://localhost:8000/curl.txt'); + $curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)); $this->assertEquals('This is a testfile for cURL.', $curl->getResponseBody()); - - $this->stopPhpWebserver(); } public function testGetResponseContentType() { - $this->startPhpWebserver(); - $curl = new Curl(); - $curl->exec('http://localhost:8000/curl.txt'); + $curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)); $this->assertEquals('text/plain; charset=UTF-8', $curl->getResponseContentType()); - $curl->exec('http://localhost:8000/404.txt'); + $curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT)); $this->assertEquals('text/html; charset=UTF-8', $curl->getResponseContentType()); - - $this->stopPhpWebserver(); } public function testGetResponseHeaders() { - $this->startPhpWebserver(); - $curl = new Curl(); - $curl->exec('http://localhost:8000/curl.txt'); - $this->assertEquals(122, strlen($curl->getResponseHeaders())); + $curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)); + $this->assertEquals(117 + self::$websererPortLength, strlen($curl->getResponseHeaders())); - $curl->exec('http://localhost:8000/404.txt'); - $this->assertEquals(130, strlen($curl->getResponseHeaders())); - - $this->stopPhpWebserver(); + $curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT)); + $this->assertEquals(124 + self::$websererPortLength, strlen($curl->getResponseHeaders())); } public function testGetResponseStatusCode() { - $this->startPhpWebserver(); - $curl = new Curl(); - $curl->exec('http://localhost:8000/curl.txt'); + $curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)); $this->assertEquals(200, $curl->getResponseStatusCode()); - $curl->exec('http://localhost:8000/404.txt'); + $curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT)); $this->assertEquals(404, $curl->getResponseStatusCode()); - - $this->stopPhpWebserver(); - } - - public function testGetResponseStatusMessage() - { - $this->startPhpWebserver(); - - $curl = new Curl(); - - $curl->exec('http://localhost:8000/curl.txt'); - $this->assertEquals('OK', $curl->getResponseStatusMessage()); - - $curl->exec('http://localhost:8000/404.txt'); - $this->assertEquals('Not Found', $curl->getResponseStatusMessage()); - - $this->stopPhpWebserver(); } } diff --git a/Tests/WsdlDownloaderTest.php b/Tests/WsdlDownloaderTest.php index 8f3825f..f42e2e7 100644 --- a/Tests/WsdlDownloaderTest.php +++ b/Tests/WsdlDownloaderTest.php @@ -13,256 +13,245 @@ namespace BeSimple\SoapClient\Tests; use BeSimple\SoapClient\WsdlDownloader; +use BeSimple\SoapCommon\Cache; use BeSimple\SoapClient\Curl; +use org\bovigo\vfs\vfsStream; +use org\bovigo\vfs\vfsStreamWrapper; /** * @author Andreas Schamberger + * @author Francis Besset */ -class WsdlDownloaderTest extends \PHPUnit_Framework_TestCase +class WsdlDownloaderTest extends AbstractWebserverTest { - protected $webserverProcessId; - - protected function startPhpWebserver() + /** + * @dataProvider provideDownload + */ + public function testDownload($source, $regexp, $nbDownloads) { - $this->markTestSkipped('Start a local webserver is not the best practice'); - - $dir = __DIR__.DIRECTORY_SEPARATOR.'Fixtures'; - if ('Windows' == substr(php_uname('s'), 0, 7)) { - $powershellCommand = "\$app = start-process php.exe -ArgumentList '-S localhost:8000 -t ".$dir."' -WindowStyle 'Hidden' -passthru; Echo \$app.Id;"; - $shellCommand = 'powershell -command "& {'.$powershellCommand.'}"'; - } else { - $shellCommand = "nohup php -S localhost:8000 -t ".$dir." &"; - } - $output = array(); - exec($shellCommand, $output); - $this->webserverProcessId = $output[0]; // pid is in first element - } + $wsdlCacheDir = vfsStream::setup('wsdl'); + $wsdlCacheUrl = $wsdlCacheDir->url('wsdl'); - protected function stopPhpWebserver() - { - if (!is_null($this->webserverProcessId)) { - if ('Windows' == substr(php_uname('s'), 0, 7)) { - exec('TASKKILL /F /PID ' . $this->webserverProcessId); - } else { - exec('kill ' . $this->webserverProcessId); - } - $this->webserverProcessId = null; - } - } + Cache::setEnabled(Cache::ENABLED); + Cache::setDirectory($wsdlCacheUrl); + $cacheDirForRegExp = preg_quote($wsdlCacheUrl, '#'); - public function testDownload() - { - $this->startPhpWebserver(); + $wsdlDownloader = new WsdlDownloader(new Curl()); + $this->assertCount(0, $wsdlCacheDir->getChildren()); - $curl = new Curl(); - $wd = new WsdlDownloader($curl); + $cacheFileName = $wsdlDownloader->download($source); + $this->assertCount($nbDownloads, $wsdlCacheDir->getChildren()); - $cacheDir = ini_get('soap.wsdl_cache_dir'); - if (!is_dir($cacheDir)) { - $cacheDir = sys_get_temp_dir(); - $cacheDirForRegExp = preg_quote($cacheDir); - } + $this->assertRegExp('#'.sprintf($regexp, $cacheDirForRegExp).'#', file_get_contents($cacheFileName)); + } - $tests = array( - 'localWithAbsolutePath' => array( - 'source' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/xsdinclude/xsdinctest_absolute.xml', - 'assertRegExp' => '~.*'.$cacheDirForRegExp.'\\\wsdl_.*\.cache.*~', + public function provideDownload() + { + return array( + array( + __DIR__.DIRECTORY_SEPARATOR.'Fixtures/xsdinclude/xsdinctest_absolute.xml', + '%s/wsdl_[a-f0-9]{32}\.cache', + 2, ), - 'localWithRelativePath' => array( - 'source' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/xsdinclude/xsdinctest_relative.xml', - 'assertRegExp' => '~.*\.\./type_include\.xsd.*~', + array( + __DIR__.DIRECTORY_SEPARATOR.'Fixtures/xsdinclude/xsdinctest_relative.xml', + '\.\./type_include\.xsd', + 1, ), - 'remoteWithAbsolutePath' => array( - 'source' => 'http://localhost:8000/xsdinclude/xsdinctest_absolute.xml', - 'assertRegExp' => '~.*'.$cacheDirForRegExp.'\\\wsdl_.*\.cache.*~', + array( + sprintf('http://localhost:%d/xsdinclude/xsdinctest_absolute.xml', WEBSERVER_PORT), + '%s/wsdl_[a-f0-9]{32}\.cache', + 2, ), - 'remoteWithAbsolutePath' => array( - 'source' => 'http://localhost:8000/xsdinclude/xsdinctest_relative.xml', - 'assertRegExp' => '~.*'.$cacheDirForRegExp.'\\\wsdl_.*\.cache.*~', + array( + sprintf('http://localhost:%d/xsdinclude/xsdinctest_relative.xml', WEBSERVER_PORT), + '%s/wsdl_[a-f0-9]{32}\.cache', + 2, ), ); - - foreach ($tests as $name => $values) { - $cacheFileName = $wd->download($values['source']); - $result = file_get_contents($cacheFileName); - $this->assertRegExp($values['assertRegExp'], $result, $name); - unlink($cacheFileName); - } - - $this->stopPhpWebserver(); } public function testIsRemoteFile() { - $curl = new Curl(); - $wd = new WsdlDownloader($curl); - - $class = new \ReflectionClass($wd); - $method = $class->getMethod('isRemoteFile'); - $method->setAccessible(true); - - $this->assertTrue($method->invoke($wd, 'http://www.php.net/')); - $this->assertTrue($method->invoke($wd, 'http://localhost/')); - $this->assertTrue($method->invoke($wd, 'http://mylocaldomain/')); - $this->assertTrue($method->invoke($wd, 'http://www.php.net/dir/test.html')); - $this->assertTrue($method->invoke($wd, 'http://localhost/dir/test.html')); - $this->assertTrue($method->invoke($wd, 'http://mylocaldomain/dir/test.html')); - $this->assertTrue($method->invoke($wd, 'https://www.php.net/')); - $this->assertTrue($method->invoke($wd, 'https://localhost/')); - $this->assertTrue($method->invoke($wd, 'https://mylocaldomain/')); - $this->assertTrue($method->invoke($wd, 'https://www.php.net/dir/test.html')); - $this->assertTrue($method->invoke($wd, 'https://localhost/dir/test.html')); - $this->assertTrue($method->invoke($wd, 'https://mylocaldomain/dir/test.html')); - $this->assertFalse($method->invoke($wd, 'c:/dir/test.html')); - $this->assertFalse($method->invoke($wd, '/dir/test.html')); - $this->assertFalse($method->invoke($wd, '../dir/test.html')); + $wsdlDownloader = new WsdlDownloader(new Curl()); + + $r = new \ReflectionClass($wsdlDownloader); + $m = $r->getMethod('isRemoteFile'); + $m->setAccessible(true); + + $this->assertTrue($m->invoke($wsdlDownloader, 'http://www.php.net/')); + $this->assertTrue($m->invoke($wsdlDownloader, 'http://localhost/')); + $this->assertTrue($m->invoke($wsdlDownloader, 'http://mylocaldomain/')); + $this->assertTrue($m->invoke($wsdlDownloader, 'http://www.php.net/dir/test.html')); + $this->assertTrue($m->invoke($wsdlDownloader, 'http://localhost/dir/test.html')); + $this->assertTrue($m->invoke($wsdlDownloader, 'http://mylocaldomain/dir/test.html')); + $this->assertTrue($m->invoke($wsdlDownloader, 'https://www.php.net/')); + $this->assertTrue($m->invoke($wsdlDownloader, 'https://localhost/')); + $this->assertTrue($m->invoke($wsdlDownloader, 'https://mylocaldomain/')); + $this->assertTrue($m->invoke($wsdlDownloader, 'https://www.php.net/dir/test.html')); + $this->assertTrue($m->invoke($wsdlDownloader, 'https://localhost/dir/test.html')); + $this->assertTrue($m->invoke($wsdlDownloader, 'https://mylocaldomain/dir/test.html')); + $this->assertFalse($m->invoke($wsdlDownloader, 'c:/dir/test.html')); + $this->assertFalse($m->invoke($wsdlDownloader, '/dir/test.html')); + $this->assertFalse($m->invoke($wsdlDownloader, '../dir/test.html')); } - public function testResolveWsdlIncludes() + /** + * @dataProvider provideResolveWsdlIncludes + */ + public function testResolveWsdlIncludes($source, $cacheFile, $remoteParentUrl, $regexp, $nbDownloads) { - $this->startPhpWebserver(); - - $curl = new Curl(); - $wd = new WsdlDownloader($curl); - - $class = new \ReflectionClass($wd); - $method = $class->getMethod('resolveRemoteIncludes'); - $method->setAccessible(true); - - $cacheDir = ini_get('soap.wsdl_cache_dir'); - if (!is_dir($cacheDir)) { - $cacheDir = sys_get_temp_dir(); - $cacheDirForRegExp = preg_quote($cacheDir); - } - - $remoteUrlAbsolute = 'http://localhost:8000/wsdlinclude/wsdlinctest_absolute.xml'; - $remoteUrlRelative = 'http://localhost:8000/wsdlinclude/wsdlinctest_relative.xml'; - $tests = array( - 'localWithAbsolutePath' => array( - 'source' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/wsdlinclude/wsdlinctest_absolute.xml', - 'cacheFile' => $cacheDir.'/cache_local_absolute.xml', - 'remoteParentUrl' => null, - 'assertRegExp' => '~.*'.$cacheDirForRegExp.'\\\wsdl_.*\.cache.*~', + $wsdlCacheDir = vfsStream::setup('wsdl'); + $wsdlCacheUrl = $wsdlCacheDir->url('wsdl'); + + Cache::setEnabled(Cache::ENABLED); + Cache::setDirectory($wsdlCacheUrl); + $cacheDirForRegExp = preg_quote($wsdlCacheUrl, '#'); + + $wsdlDownloader = new WsdlDownloader(new Curl()); + $r = new \ReflectionClass($wsdlDownloader); + $m = $r->getMethod('resolveRemoteIncludes'); + $m->setAccessible(true); + + $this->assertCount(0, $wsdlCacheDir->getChildren()); + + $cacheFile = sprintf($cacheFile, $wsdlCacheUrl); + $m->invoke($wsdlDownloader, file_get_contents($source), $cacheFile, $remoteParentUrl); + $this->assertCount($nbDownloads, $wsdlCacheDir->getChildren()); + + $this->assertRegExp('#'.sprintf($regexp, $cacheDirForRegExp).'#', file_get_contents($cacheFile)); + } + + public function provideResolveWsdlIncludes() + { + $remoteUrlAbsolute = sprintf('http://localhost:%d/wsdlinclude/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', + '%s/cache_local_absolute.xml', + null, + '%s/wsdl_[a-f0-9]{32}.cache', + 2, ), - 'localWithRelativePath' => array( - 'source' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/wsdlinclude/wsdlinctest_relative.xml', - 'cacheFile' => $cacheDir.'/cache_local_relative.xml', - 'remoteParentUrl' => null, - 'assertRegExp' => '~.*\.\./wsdl_include\.wsdl.*~', + array( + __DIR__.DIRECTORY_SEPARATOR.'Fixtures/wsdlinclude/wsdlinctest_relative.xml', + '%s/cache_local_relative.xml', + null, + '\.\./wsdl_include\.wsdl', + 1, ), - 'remoteWithAbsolutePath' => array( - 'source' => $remoteUrlAbsolute, - 'cacheFile' => $cacheDir.'/cache_remote_absolute.xml', - 'remoteParentUrl' => $remoteUrlAbsolute, - 'assertRegExp' => '~.*'.$cacheDirForRegExp.'\\\wsdl_.*\.cache.*~', + array( + $remoteUrlAbsolute, + '%s/cache_remote_absolute.xml', + $remoteUrlAbsolute, + '%s/wsdl_[a-f0-9]{32}\.cache', + 2, ), - 'remoteWithAbsolutePath' => array( - 'source' => $remoteUrlRelative, - 'cacheFile' => $cacheDir.'/cache_remote_relative.xml', - 'remoteParentUrl' => $remoteUrlRelative, - 'assertRegExp' => '~.*'.$cacheDirForRegExp.'\\\wsdl_.*\.cache.*~', + array( + $remoteUrlRelative, + '%s/cache_remote_relative.xml', + $remoteUrlRelative, + '%s/wsdl_[a-f0-9]{32}\.cache', + 2 ), ); + } + + /** + * @dataProvider provideResolveXsdIncludes + */ + public function testResolveXsdIncludes($source, $cacheFile, $remoteParentUrl, $regexp, $nbDownloads) + { + $wsdlCacheDir = vfsStream::setup('wsdl'); + $wsdlCacheUrl = $wsdlCacheDir->url('wsdl'); + + Cache::setEnabled(Cache::ENABLED); + Cache::setDirectory($wsdlCacheUrl); + $cacheDirForRegExp = preg_quote($wsdlCacheUrl, '#'); + + $wsdlDownloader = new WsdlDownloader(new Curl()); + $r = new \ReflectionClass($wsdlDownloader); + $m = $r->getMethod('resolveRemoteIncludes'); + $m->setAccessible(true); - foreach ($tests as $name => $values) { - $wsdl = file_get_contents($values['source']); - $method->invoke($wd, $wsdl, $values['cacheFile'], $values['remoteParentUrl']); - $result = file_get_contents($values['cacheFile']); - $this->assertRegExp($values['assertRegExp'], $result, $name); - unlink($values['cacheFile']); - } + $this->assertCount(0, $wsdlCacheDir->getChildren()); - $this->stopPhpWebserver(); + $cacheFile = sprintf($cacheFile, $wsdlCacheUrl); + $m->invoke($wsdlDownloader, file_get_contents($source), $cacheFile, $remoteParentUrl); + $this->assertCount($nbDownloads, $wsdlCacheDir->getChildren()); + + $this->assertRegExp('#'.sprintf($regexp, $cacheDirForRegExp).'#', file_get_contents($cacheFile)); } - public function testResolveXsdIncludes() + public function provideResolveXsdIncludes() { - $this->startPhpWebserver(); - - $curl = new Curl(); - $wd = new WsdlDownloader($curl); - - $class = new \ReflectionClass($wd); - $method = $class->getMethod('resolveRemoteIncludes'); - $method->setAccessible(true); - - $cacheDir = ini_get('soap.wsdl_cache_dir'); - if (!is_dir($cacheDir)) { - $cacheDir = sys_get_temp_dir(); - $cacheDirForRegExp = preg_quote($cacheDir); - } - - $remoteUrlAbsolute = 'http://localhost:8000/xsdinclude/xsdinctest_absolute.xml'; - $remoteUrlRelative = 'http://localhost:8000/xsdinclude/xsdinctest_relative.xml'; - $tests = array( - 'localWithAbsolutePath' => array( - 'source' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/xsdinclude/xsdinctest_absolute.xml', - 'cacheFile' => $cacheDir.'/cache_local_absolute.xml', - 'remoteParentUrl' => null, - 'assertRegExp' => '~.*'.$cacheDirForRegExp.'\\\wsdl_.*\.cache.*~', + $remoteUrlAbsolute = sprintf('http://localhost:%d/xsdinclude/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', + '%s/cache_local_absolute.xml', + null, + '%s/wsdl_[a-f0-9]{32}\.cache', + 2, ), - 'localWithRelativePath' => array( - 'source' => __DIR__.DIRECTORY_SEPARATOR.'Fixtures/xsdinclude/xsdinctest_relative.xml', - 'cacheFile' => $cacheDir.'/cache_local_relative.xml', - 'remoteParentUrl' => null, - 'assertRegExp' => '~.*\.\./type_include\.xsd.*~', + array( + __DIR__.DIRECTORY_SEPARATOR.'Fixtures/xsdinclude/xsdinctest_relative.xml', + '%s/cache_local_relative.xml', + null, + '\.\./type_include\.xsd', + 1, ), - 'remoteWithAbsolutePath' => array( - 'source' => $remoteUrlAbsolute, - 'cacheFile' => $cacheDir.'/cache_remote_absolute.xml', - 'remoteParentUrl' => $remoteUrlAbsolute, - 'assertRegExp' => '~.*'.$cacheDirForRegExp.'\\\wsdl_.*\.cache.*~', + array( + $remoteUrlAbsolute, + '%s/cache_remote_absolute.xml', + $remoteUrlAbsolute, + '%s/wsdl_[a-f0-9]{32}\.cache', + 2, ), - 'remoteWithAbsolutePath' => array( - 'source' => $remoteUrlRelative, - 'cacheFile' => $cacheDir.'/cache_remote_relative.xml', - 'remoteParentUrl' => $remoteUrlRelative, - 'assertRegExp' => '~.*'.$cacheDirForRegExp.'\\\wsdl_.*\.cache.*~', + array( + $remoteUrlRelative, + '%s/cache_remote_relative.xml', + $remoteUrlRelative, + '%s/wsdl_[a-f0-9]{32}\.cache', + 2, ), ); - - foreach ($tests as $name => $values) { - $wsdl = file_get_contents($values['source']); - $method->invoke($wd, $wsdl, $values['cacheFile'], $values['remoteParentUrl']); - $result = file_get_contents($values['cacheFile']); - $this->assertRegExp($values['assertRegExp'], $result, $name); - unlink($values['cacheFile']); - } - - $this->stopPhpWebserver(); } public function testResolveRelativePathInUrl() { - $curl = new Curl(); - $wd = new WsdlDownloader($curl); + $wsdlDownloader = new WsdlDownloader(new Curl()); - $class = new \ReflectionClass($wd); - $method = $class->getMethod('resolveRelativePathInUrl'); - $method->setAccessible(true); + $r = new \ReflectionClass($wsdlDownloader); + $m = $r->getMethod('resolveRelativePathInUrl'); + $m->setAccessible(true); - $this->assertEquals('http://localhost:8080/test', $method->invoke($wd, 'http://localhost:8080/sub', '/test')); - $this->assertEquals('http://localhost:8080/test', $method->invoke($wd, 'http://localhost:8080/sub/', '/test')); + $this->assertEquals('http://localhost:8080/test', $m->invoke($wsdlDownloader, 'http://localhost:8080/sub', '/test')); + $this->assertEquals('http://localhost:8080/test', $m->invoke($wsdlDownloader, 'http://localhost:8080/sub/', '/test')); - $this->assertEquals('http://localhost/test', $method->invoke($wd, 'http://localhost/sub', '/test')); - $this->assertEquals('http://localhost/test', $method->invoke($wd, 'http://localhost/sub/', '/test')); + $this->assertEquals('http://localhost/test', $m->invoke($wsdlDownloader, 'http://localhost/sub', '/test')); + $this->assertEquals('http://localhost/test', $m->invoke($wsdlDownloader, 'http://localhost/sub/', '/test')); - $this->assertEquals('http://localhost/test', $method->invoke($wd, 'http://localhost', './test')); - $this->assertEquals('http://localhost/test', $method->invoke($wd, 'http://localhost/', './test')); + $this->assertEquals('http://localhost/test', $m->invoke($wsdlDownloader, 'http://localhost', './test')); + $this->assertEquals('http://localhost/test', $m->invoke($wsdlDownloader, 'http://localhost/', './test')); - $this->assertEquals('http://localhost/sub/test', $method->invoke($wd, 'http://localhost/sub/sub', './test')); - $this->assertEquals('http://localhost/sub/sub/test', $method->invoke($wd, 'http://localhost/sub/sub/', './test')); + $this->assertEquals('http://localhost/sub/test', $m->invoke($wsdlDownloader, 'http://localhost/sub/sub', './test')); + $this->assertEquals('http://localhost/sub/sub/test', $m->invoke($wsdlDownloader, 'http://localhost/sub/sub/', './test')); - $this->assertEquals('http://localhost/test', $method->invoke($wd, 'http://localhost/sub/sub', '../test')); - $this->assertEquals('http://localhost/sub/test', $method->invoke($wd, 'http://localhost/sub/sub/', '../test')); + $this->assertEquals('http://localhost/test', $m->invoke($wsdlDownloader, 'http://localhost/sub/sub', '../test')); + $this->assertEquals('http://localhost/sub/test', $m->invoke($wsdlDownloader, 'http://localhost/sub/sub/', '../test')); - $this->assertEquals('http://localhost/test', $method->invoke($wd, 'http://localhost/sub/sub/sub', '../../test')); - $this->assertEquals('http://localhost/sub/test', $method->invoke($wd, 'http://localhost/sub/sub/sub/', '../../test')); + $this->assertEquals('http://localhost/test', $m->invoke($wsdlDownloader, 'http://localhost/sub/sub/sub', '../../test')); + $this->assertEquals('http://localhost/sub/test', $m->invoke($wsdlDownloader, 'http://localhost/sub/sub/sub/', '../../test')); - $this->assertEquals('http://localhost/test', $method->invoke($wd, 'http://localhost/sub/sub/sub/sub', '../../../test')); - $this->assertEquals('http://localhost/sub/test', $method->invoke($wd, 'http://localhost/sub/sub/sub/sub/', '../../../test')); + $this->assertEquals('http://localhost/test', $m->invoke($wsdlDownloader, 'http://localhost/sub/sub/sub/sub', '../../../test')); + $this->assertEquals('http://localhost/sub/test', $m->invoke($wsdlDownloader, 'http://localhost/sub/sub/sub/sub/', '../../../test')); - $this->assertEquals('http://localhost/test', $method->invoke($wd, 'http://localhost/sub/sub/sub', '../../../test')); - $this->assertEquals('http://localhost/test', $method->invoke($wd, 'http://localhost/sub/sub/sub/', '../../../test')); + $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')); } } diff --git a/WsdlDownloader.php b/WsdlDownloader.php index 9f62fe4..6e403ce 100644 --- a/WsdlDownloader.php +++ b/WsdlDownloader.php @@ -12,6 +12,7 @@ namespace BeSimple\SoapClient; +use BeSimple\SoapCommon\Cache; use BeSimple\SoapCommon\Helper; /** @@ -66,22 +67,18 @@ class WsdlDownloader * @param boolean $resolveRemoteIncludes WSDL/XSD include enabled? * @param boolean $cacheWsdl Cache constant */ - public function __construct(Curl $curl, $resolveRemoteIncludes = true, $cacheWsdl = WSDL_CACHE_DISK) + public function __construct(Curl $curl, $resolveRemoteIncludes = true, $cacheWsdl = Cache::TYPE_DISK) { - $this->curl = $curl; - $this->resolveRemoteIncludes = $resolveRemoteIncludes; + $this->curl = $curl; + $this->resolveRemoteIncludes = (Boolean) $resolveRemoteIncludes; + // get current WSDL caching config - $this->cacheEnabled = (bool) ini_get('soap.wsdl_cache_enabled'); - if ($this->cacheEnabled === true - && $cacheWsdl === WSDL_CACHE_NONE) { - $this->cacheEnabled = false; - } - $this->cacheDir = ini_get('soap.wsdl_cache_dir'); - if (!is_dir($this->cacheDir)) { - $this->cacheDir = sys_get_temp_dir(); + $this->cacheEnabled = $cacheWsdl === Cache::TYPE_NONE ? Cache::DISABLED : Cache::ENABLED == Cache::isEnabled(); + + if ($this->cacheEnabled) { + $this->cacheDir = Cache::getDirectory(); + $this->cacheTtl = Cache::getLifetime(); } - $this->cacheDir = rtrim($this->cacheDir, '/\\'); - $this->cacheTtl = ini_get('soap.wsdl_cache_ttl'); } /** @@ -96,40 +93,39 @@ public function download($wsdl) // download and cache remote WSDL files or local ones where we want to // resolve remote XSD includes $isRemoteFile = $this->isRemoteFile($wsdl); - if ($isRemoteFile === true || $this->resolveRemoteIncludes === true) { - $cacheFile = $this->cacheDir . DIRECTORY_SEPARATOR . 'wsdl_' . md5($wsdl) . '.cache'; - if ($this->cacheEnabled === false - || !file_exists($cacheFile) - || (filemtime($cacheFile) + $this->cacheTtl) < time()) { - if ($isRemoteFile === true) { + if ($isRemoteFile || $this->resolveRemoteIncludes) { + $cacheFilePath = $this->cacheDir.DIRECTORY_SEPARATOR.'wsdl_'.md5($wsdl).'.cache'; + + if (!$this->cacheEnabled || !file_exists($cacheFilePath) || (filemtime($cacheFilePath) + $this->cacheTtl) < time()) { + if ($isRemoteFile) { // execute request $responseSuccessfull = $this->curl->exec($wsdl); // get content - if ($responseSuccessfull === true) { + if ($responseSuccessfull) { $response = $this->curl->getResponseBody(); - if ($this->resolveRemoteIncludes === true) { - $this->resolveRemoteIncludes($response, $cacheFile, $wsdl); + + if ($this->resolveRemoteIncludes) { + $this->resolveRemoteIncludes($response, $cacheFilePath, $wsdl); } else { - file_put_contents($cacheFile, $response); + file_put_contents($cacheFilePath, $response); } } else { throw new \ErrorException("SOAP-ERROR: Parsing WSDL: Couldn't load from '" . $wsdl ."'"); } } elseif (file_exists($wsdl)) { $response = file_get_contents($wsdl); - $this->resolveRemoteIncludes($response, $cacheFile); + $this->resolveRemoteIncludes($response, $cacheFilePath); } else { throw new \ErrorException("SOAP-ERROR: Parsing WSDL: Couldn't load from '" . $wsdl ."'"); } } - return $cacheFile; + return $cacheFilePath; } elseif (file_exists($wsdl)) { - return realpath($wsdl); - } else { - throw new \ErrorException("SOAP-ERROR: Parsing WSDL: Couldn't load from '" . $wsdl ."'"); } + + throw new \ErrorException("SOAP-ERROR: Parsing WSDL: Couldn't load from '" . $wsdl ."'"); } /** @@ -141,35 +137,36 @@ public function download($wsdl) */ private function isRemoteFile($file) { - $isRemoteFile = false; // @parse_url to suppress E_WARNING for invalid urls - if (($url = @parse_url($file)) !== false) { - if (isset($url['scheme']) && substr($url['scheme'], 0, 4) == 'http') { - $isRemoteFile = true; + if (false !== $url = @parse_url($file)) { + if (isset($url['scheme']) && 'http' === substr($url['scheme'], 0, 4)) { + return true; } } - return $isRemoteFile; + return false; } /** * Resolves remote WSDL/XSD includes within the WSDL files. * - * @param string $xml XML file - * @param string $cacheFile Cache file name - * @param boolean $parentFile Parent file name + * @param string $xml XML file + * @param string $cacheFilePath Cache file name + * @param boolean $parentFilePath Parent file name * * @return void */ - private function resolveRemoteIncludes($xml, $cacheFile, $parentFile = null) + private function resolveRemoteIncludes($xml, $cacheFilePath, $parentFilePath = null) { $doc = new \DOMDocument(); $doc->loadXML($xml); + $xpath = new \DOMXPath($doc); $xpath->registerNamespace(Helper::PFX_XML_SCHEMA, Helper::NS_XML_SCHEMA); $xpath->registerNamespace(Helper::PFX_WSDL, Helper::NS_WSDL); + // WSDL include/import - $query = './/' . Helper::PFX_WSDL . ':include | .//' . Helper::PFX_WSDL . ':import'; + $query = './/'.Helper::PFX_WSDL.':include | .//'.Helper::PFX_WSDL.':import'; $nodes = $xpath->query($query); if ($nodes->length > 0) { foreach ($nodes as $node) { @@ -177,32 +174,34 @@ private function resolveRemoteIncludes($xml, $cacheFile, $parentFile = null) if ($this->isRemoteFile($location)) { $location = $this->download($location); $node->setAttribute('location', $location); - } elseif (!is_null($parentFile)) { - $location = $this->resolveRelativePathInUrl($parentFile, $location); + } elseif (null !== $parentFilePath) { + $location = $this->resolveRelativePathInUrl($parentFilePath, $location); $location = $this->download($location); $node->setAttribute('location', $location); } } } + // XML schema include/import - $query = './/' . Helper::PFX_XML_SCHEMA . ':include | .//' . Helper::PFX_XML_SCHEMA . ':import'; + $query = './/'.Helper::PFX_XML_SCHEMA.':include | .//'.Helper::PFX_XML_SCHEMA.':import'; $nodes = $xpath->query($query); if ($nodes->length > 0) { foreach ($nodes as $node) { if ($node->hasAttribute('schemaLocation')) { - $schemaLocation = $node->getAttribute('schemaLocation'); - if ($this->isRemoteFile($schemaLocation)) { - $schemaLocation = $this->download($schemaLocation); - $node->setAttribute('schemaLocation', $schemaLocation); - } elseif (null !== $parentFile) { - $schemaLocation = $this->resolveRelativePathInUrl($parentFile, $schemaLocation); - $schemaLocation = $this->download($schemaLocation); - $node->setAttribute('schemaLocation', $schemaLocation); + $schemaLocation = $node->getAttribute('schemaLocation'); + if ($this->isRemoteFile($schemaLocation)) { + $schemaLocation = $this->download($schemaLocation); + $node->setAttribute('schemaLocation', $schemaLocation); + } elseif (null !== $parentFilePath) { + $schemaLocation = $this->resolveRelativePathInUrl($parentFilePath, $schemaLocation); + $schemaLocation = $this->download($schemaLocation); + $node->setAttribute('schemaLocation', $schemaLocation); } } } } - $doc->save($cacheFile); + + $doc->save($cacheFilePath); } /** @@ -216,46 +215,53 @@ private function resolveRemoteIncludes($xml, $cacheFile, $parentFile = null) private function resolveRelativePathInUrl($base, $relative) { $urlParts = parse_url($base); + // combine base path with relative path - if (isset($urlParts['path']) && strpos($relative, '/') === 0) { + if (isset($urlParts['path']) && '/' === $relative{0}) { // $relative is absolute path from domain (starts with /) $path = $relative; } elseif (isset($urlParts['path']) && strrpos($urlParts['path'], '/') === (strlen($urlParts['path']) )) { // base path is directory - $path = $urlParts['path'] . $relative; + $path = $urlParts['path'].$relative; } elseif (isset($urlParts['path'])) { // strip filename from base path - $path = substr($urlParts['path'], 0, strrpos($urlParts['path'], '/')) . '/' . $relative; + $path = substr($urlParts['path'], 0, strrpos($urlParts['path'], '/')).'/'.$relative; } else { // no base path - $path = '/' . $relative; + $path = '/'.$relative; } + // foo/./bar ==> foo/bar - $path = preg_replace('~/\./~', '/', $path); // remove double slashes - $path = preg_replace('~/+~', '/', $path); + $path = preg_replace(array('#/\./#', '#/+#'), '/', $path); + // split path by '/' $parts = explode('/', $path); + // resolve /../ foreach ($parts as $key => $part) { - if ($part == "..") { - $keyToDelete = $key-1; + if ('..' === $part) { + $keyToDelete = $key - 1; + while ($keyToDelete > 0) { if (isset($parts[$keyToDelete])) { unset($parts[$keyToDelete]); + break; - } else { - $keyToDelete--; } + + $keyToDelete--; } + unset($parts[$key]); } } - $hostname = $urlParts['scheme'] . '://' . $urlParts['host']; + + $hostname = $urlParts['scheme'].'://'.$urlParts['host']; if (isset($urlParts['port'])) { - $hostname .= ':' . $urlParts['port']; + $hostname .= ':'.$urlParts['port']; } - return $hostname . implode('/', $parts); + return $hostname.implode('/', $parts); } -} \ No newline at end of file +} diff --git a/composer.json b/composer.json index 8cf7483..352d888 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,10 @@ "besimple/soap-common": "self.version", "ass/xmlsecurity": "dev-master" }, + "require-dev": { + "mikey179/vfsStream": "dev-master", + "symfony/process": ">=2.3,<2.4-dev" + }, "autoload": { "psr-0": { "BeSimple\\SoapClient": "" } }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 13bd743..e223604 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,6 +11,11 @@ syntaxCheck="false" bootstrap="vendor/autoload.php" > + + + + + ./Tests/ From fb75277cd1ce7c958cf6766c8cb5c2b1ce6736ef Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Wed, 24 Jul 2013 23:44:50 +0200 Subject: [PATCH 4/7] Fixed syntax for PHP 5.3 --- Tests/AbstractWebserverTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/AbstractWebserverTest.php b/Tests/AbstractWebserverTest.php index 54e5be4..a7bc6d4 100644 --- a/Tests/AbstractWebserverTest.php +++ b/Tests/AbstractWebserverTest.php @@ -32,9 +32,10 @@ public static function setUpBeforeClass() self::markTestSkipped('PHP Webserver is available from PHP 5.4'); } + $phpFinder = new PhpExecutableFinder(); self::$webserver = ProcessBuilder::create(array( 'exec', // used exec binary (https://github.com/symfony/symfony/issues/5759) - (new PhpExecutableFinder())->find(), + $phpFinder->find(), '-S', sprintf('localhost:%d', WEBSERVER_PORT), '-t', From 11d54c69d58b4f7f6400c0a5fb21a2795a0b2786 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Thu, 25 Jul 2013 09:29:22 +0200 Subject: [PATCH 5/7] 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": { From 0317e363c813a6bff7921ede464b000aad56efae Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Fri, 16 Aug 2013 16:27:30 +0200 Subject: [PATCH 6/7] Updated version to 0.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3df0b70..ed4f632 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "0.1-dev" + "dev-master": "0.2-dev" } } } From 074eb1927faefa9545511078834bdbbd3e54a657 Mon Sep 17 00:00:00 2001 From: Lukas Kahwe Smith Date: Wed, 18 Sep 2013 13:18:40 +0200 Subject: [PATCH 7/7] allow Symfony2.4+ --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ed4f632..b61b359 100644 --- a/composer.json +++ b/composer.json @@ -28,8 +28,8 @@ }, "require-dev": { "mikey179/vfsStream": "dev-master", - "symfony/filesystem": ">=2.3,<2.4-dev", - "symfony/process": ">=2.3,<2.4-dev" + "symfony/filesystem": "~2.3", + "symfony/process": "~2.3" }, "autoload": { "psr-0": { "BeSimple\\SoapClient": "" }