From c54b2925fec9ca3479e0a1d5ae21340dd71a1533 Mon Sep 17 00:00:00 2001 From: Andreas Schamberger Date: Sun, 16 Oct 2011 17:35:14 +0200 Subject: [PATCH] * fixed missing port number in WsdlDownloader * fixed boolean assertions --- src/BeSimple/SoapClient/WsdlDownloader.php | 6 +++- .../Tests/SoapClient/WsdlDownloaderTest.php | 33 ++++++++++--------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/BeSimple/SoapClient/WsdlDownloader.php b/src/BeSimple/SoapClient/WsdlDownloader.php index 8ccf889..55c7d90 100644 --- a/src/BeSimple/SoapClient/WsdlDownloader.php +++ b/src/BeSimple/SoapClient/WsdlDownloader.php @@ -218,6 +218,10 @@ class WsdlDownloader unset($parts[$key]); } } - return $urlParts['scheme'] . '://' . $urlParts['host'] . implode('/', $parts); + $hostname = $urlParts['scheme'] . '://' . $urlParts['host']; + if (isset($urlParts['port'])) { + $hostname .= ':' . $urlParts['port']; + } + return $hostname . implode('/', $parts); } } \ No newline at end of file diff --git a/tests/BeSimple/Tests/SoapClient/WsdlDownloaderTest.php b/tests/BeSimple/Tests/SoapClient/WsdlDownloaderTest.php index fc006ae..09ec14c 100644 --- a/tests/BeSimple/Tests/SoapClient/WsdlDownloaderTest.php +++ b/tests/BeSimple/Tests/SoapClient/WsdlDownloaderTest.php @@ -98,21 +98,21 @@ class WsdlDownloaderTest extends \PHPUnit_Framework_TestCase $method = $class->getMethod('isRemoteFile'); $method->setAccessible(true); - $this->assertEquals(true, $method->invoke($wd, 'http://www.php.net/')); - $this->assertEquals(true, $method->invoke($wd, 'http://localhost/')); - $this->assertEquals(true, $method->invoke($wd, 'http://mylocaldomain/')); - $this->assertEquals(true, $method->invoke($wd, 'http://www.php.net/dir/test.html')); - $this->assertEquals(true, $method->invoke($wd, 'http://localhost/dir/test.html')); - $this->assertEquals(true, $method->invoke($wd, 'http://mylocaldomain/dir/test.html')); - $this->assertEquals(true, $method->invoke($wd, 'https://www.php.net/')); - $this->assertEquals(true, $method->invoke($wd, 'https://localhost/')); - $this->assertEquals(true, $method->invoke($wd, 'https://mylocaldomain/')); - $this->assertEquals(true, $method->invoke($wd, 'https://www.php.net/dir/test.html')); - $this->assertEquals(true, $method->invoke($wd, 'https://localhost/dir/test.html')); - $this->assertEquals(true, $method->invoke($wd, 'https://mylocaldomain/dir/test.html')); - $this->assertEquals(false, $method->invoke($wd, 'c:/dir/test.html')); - $this->assertEquals(false, $method->invoke($wd, '/dir/test.html')); - $this->assertEquals(false, $method->invoke($wd, '../dir/test.html')); + $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')); } public function testResolveXsdIncludes() @@ -182,6 +182,9 @@ class WsdlDownloaderTest extends \PHPUnit_Framework_TestCase $method = $class->getMethod('resolveRelativePathInUrl'); $method->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/test', $method->invoke($wd, 'http://localhost/sub', '/test')); $this->assertEquals('http://localhost/test', $method->invoke($wd, 'http://localhost/sub/', '/test'));