diff --git a/composer.json b/composer.json index 4e0bc5d..f8a5573 100644 --- a/composer.json +++ b/composer.json @@ -44,6 +44,11 @@ "autoload": { "psr-0": { "BeSimple\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "": "tests/" + } + }, "extra": { "branch-alias": { "dev-master": "0.4-dev" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1cb26e7..86760be 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,17 +10,14 @@ stopOnFailure="false" syntaxCheck="false" stderr="true" - bootstrap="vendor/autoload.php" -> - + bootstrap="vendor/autoload.php"> - - src/BeSimple/SoapClient/Tests/SoapClientBuilderTest.php - src/BeSimple/SoapServer/Tests/SoapServerBuilderTest.php + + tests diff --git a/src/BeSimple/SoapClient/Tests/AbstractWebserverTest.php b/src/BeSimple/SoapClient/Tests/AbstractWebserverTest.php deleted file mode 100644 index a7bc6d4..0000000 --- a/src/BeSimple/SoapClient/Tests/AbstractWebserverTest.php +++ /dev/null @@ -1,56 +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. - */ - -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'); - } - - $phpFinder = new PhpExecutableFinder(); - self::$webserver = ProcessBuilder::create(array( - 'exec', // used exec binary (https://github.com/symfony/symfony/issues/5759) - $phpFinder->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/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/AttachmentRequest.php b/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/AttachmentRequest.php deleted file mode 100644 index e4f0236..0000000 --- a/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/AttachmentRequest.php +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/SwA.wsdl b/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/SwA.wsdl deleted file mode 100644 index d63fe2d..0000000 --- a/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/SwA.wsdl +++ /dev/null @@ -1,162 +0,0 @@ - - - BeSimpleSwaService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/WsSecuritySigEnc.wsdl b/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/WsSecuritySigEnc.wsdl deleted file mode 100644 index 620ea51..0000000 --- a/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/WsSecuritySigEnc.wsdl +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/WsSecurityUserPass.wsdl b/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/WsSecurityUserPass.wsdl deleted file mode 100644 index 6e72411..0000000 --- a/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/WsSecurityUserPass.wsdl +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/addBook.php b/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/addBook.php deleted file mode 100644 index 7a171b0..0000000 --- a/src/BeSimple/SoapClient/Tests/AxisInterop/Fixtures/addBook.php +++ /dev/null @@ -1,11 +0,0 @@ - SOAP_1_1, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_MTOM, - 'cache_wsdl' => WSDL_CACHE_NONE, - 'classmap' => array( - 'base64Binary' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\base64Binary', - 'AttachmentRequest' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\AttachmentRequest', - ), - 'proxy_host' => false, - ); - - public function testAttachment() - { - $sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/MTOM.wsdl', $this->options); - - $b64 = new base64Binary(); - $b64->_ = 'This is a test. :)'; - $b64->contentType = 'text/plain'; - - $attachment = new AttachmentRequest(); - $attachment->fileName = 'test123.txt'; - $attachment->binaryData = $b64; - - $this->assertEquals('File saved succesfully.', $sc->attachment($attachment)); - -// $fileCreatedByServer = __DIR__.'/'.$attachment->fileName; -// $this->assertEquals($b64->_, file_get_contents($fileCreatedByServer)); -// unlink($fileCreatedByServer); - } -} diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/SwA/build.xml b/src/BeSimple/SoapClient/Tests/AxisInterop/SwA/build.xml deleted file mode 100644 index 836bda8..0000000 --- a/src/BeSimple/SoapClient/Tests/AxisInterop/SwA/build.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/SwA/resources/META-INF/services.xml b/src/BeSimple/SoapClient/Tests/AxisInterop/SwA/resources/META-INF/services.xml deleted file mode 100644 index 8bac2eb..0000000 --- a/src/BeSimple/SoapClient/Tests/AxisInterop/SwA/resources/META-INF/services.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - BeSimple test service for SwA. - true - besimple.service.BeSimpleSwaService - - urn:uploadFile - - - - urn:downloadFile - - - - diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/SwA/src/besimple/service/BeSimpleSwaService.java b/src/BeSimple/SoapClient/Tests/AxisInterop/SwA/src/besimple/service/BeSimpleSwaService.java deleted file mode 100644 index b173e15..0000000 --- a/src/BeSimple/SoapClient/Tests/AxisInterop/SwA/src/besimple/service/BeSimpleSwaService.java +++ /dev/null @@ -1,78 +0,0 @@ -package besimple.service; - -import java.io.File; -import java.io.FileOutputStream; - -import javax.xml.namespace.QName; - -import javax.activation.DataHandler; -import javax.activation.FileDataSource; - -import org.apache.axiom.attachments.Attachments; -import org.apache.axiom.om.OMAbstractFactory; -import org.apache.axiom.om.OMAttribute; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMFactory; -import org.apache.axiom.om.OMNamespace; - -import org.apache.axis2.context.MessageContext; -import org.apache.axis2.context.OperationContext; -import org.apache.axis2.wsdl.WSDLConstants; - -public class BeSimpleSwaService { - - String namespace = "http://service.besimple"; - - public OMElement uploadFile(OMElement element) throws Exception { - OMElement dataElement = (OMElement)element.getFirstChildWithName(new QName(namespace, "data")); - OMAttribute hrefAttribute = dataElement.getAttribute(new QName("href")); - - String contentID = hrefAttribute.getAttributeValue(); - contentID = contentID.trim(); - if (contentID.substring(0, 3).equalsIgnoreCase("cid")) { - contentID = contentID.substring(4); - } - OMElement nameElement = (OMElement)element.getFirstChildWithName(new QName(namespace, "name")); - String name = nameElement.getText(); - - MessageContext msgCtx = MessageContext.getCurrentMessageContext(); - Attachments attachment = msgCtx.getAttachmentMap(); - DataHandler dataHandler = attachment.getDataHandler(contentID); - - File file = new File(name); - FileOutputStream fileOutputStream = new FileOutputStream(file); - dataHandler.writeTo(fileOutputStream); - fileOutputStream.flush(); - fileOutputStream.close(); - - OMFactory factory = OMAbstractFactory.getOMFactory(); - OMNamespace omNs = factory.createOMNamespace(namespace, "swa"); - OMElement wrapperElement = factory.createOMElement("uploadFileResponse", omNs); - OMElement returnElement = factory.createOMElement("return", omNs, wrapperElement); - returnElement.setText("File saved succesfully."); - - return wrapperElement; - } - - public OMElement downloadFile(OMElement element) throws Exception { - OMElement nameElement = (OMElement)element.getFirstChildWithName(new QName(namespace, "name")); - String name = nameElement.getText(); - - MessageContext msgCtxIn = MessageContext.getCurrentMessageContext(); - OperationContext operationContext = msgCtxIn.getOperationContext(); - MessageContext msgCtxOut = operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE); - - FileDataSource fileDataSource = new FileDataSource(name); - DataHandler dataHandler = new DataHandler(fileDataSource); - - String contentID = "cid:" + msgCtxOut.addAttachment(dataHandler); - - OMFactory factory = OMAbstractFactory.getOMFactory(); - OMNamespace omNs = factory.createOMNamespace(namespace, "swa"); - OMElement wrapperElement = factory.createOMElement("downloadFileResponse", omNs); - OMElement dataElement = factory.createOMElement("data", omNs, wrapperElement); - dataElement.addAttribute("href", contentID, null); - - return wrapperElement; - } -} diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/SwaAxisInteropTest.php b/src/BeSimple/SoapClient/Tests/AxisInterop/SwaAxisInteropTest.php deleted file mode 100644 index d964aa3..0000000 --- a/src/BeSimple/SoapClient/Tests/AxisInterop/SwaAxisInteropTest.php +++ /dev/null @@ -1,78 +0,0 @@ - SOAP_1_1, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_SWA, - 'cache_wsdl' => WSDL_CACHE_NONE, - 'classmap' => array( - 'downloadFile' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\downloadFile', - 'downloadFileResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\downloadFileResponse', - 'uploadFile' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\uploadFile', - 'uploadFileResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\uploadFileResponse', - ), - 'proxy_host' => false, - ); - - public function testUploadDownloadText() - { - $sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $this->options); - - $upload = new uploadFile(); - $upload->name = 'upload.txt'; - $upload->data = 'This is a test. :)'; - $result = $sc->uploadFile($upload); - - $this->assertEquals('File saved succesfully.', $result->return); - - $download = new downloadFile(); - $download->name = 'upload.txt'; - $result = $sc->downloadFile($download); - - $this->assertEquals($upload->data, $result->data); - } - - public function testUploadDownloadImage() - { - $sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $this->options); - - $upload = new uploadFile(); - $upload->name = 'image.jpg'; - $upload->data = file_get_contents(__DIR__.'/Fixtures/image.jpg'); // source: http://www.freeimageslive.com/galleries/light/pics/swirl3768.jpg; - $result = $sc->uploadFile($upload); - - $this->assertEquals('File saved succesfully.', $result->return); - - $download = new downloadFile(); - $download->name = 'image.jpg'; - $result = $sc->downloadFile($download); - - $this->assertEquals($upload->data, $result->data); - } -} diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/TestCase.php b/src/BeSimple/SoapClient/Tests/AxisInterop/TestCase.php deleted file mode 100644 index eb57435..0000000 --- a/src/BeSimple/SoapClient/Tests/AxisInterop/TestCase.php +++ /dev/null @@ -1,23 +0,0 @@ -markTestSkipped( - 'The Axis server is not started on port 8080.' - ); - } - - curl_close($ch); - } -} \ No newline at end of file diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/WsAddressingAxisInteropTest.php b/src/BeSimple/SoapClient/Tests/AxisInterop/WsAddressingAxisInteropTest.php deleted file mode 100644 index 2310476..0000000 --- a/src/BeSimple/SoapClient/Tests/AxisInterop/WsAddressingAxisInteropTest.php +++ /dev/null @@ -1,60 +0,0 @@ - - * ... - * - * - * build.xml: - * replace version.aar with version2.aar - * - * 2) Run ant build.xml in "$AXIS_HOME/samples/version" - * - */ - -use BeSimple\SoapClient\SoapClient as BeSimpleSoapClient; -use BeSimple\SoapClient\WsAddressingFilter as BeSimpleWsAddressingFilter; - -use BeSimple\SoapClient\Tests\AxisInterop\TestCase; - -class WsAddressingAxisInteropTest extends TestCase -{ - private $options = array( - 'soap_version' => SOAP_1_2, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'proxy_host' => false, - ); - - public function testSession() - { - $sc = new BeSimpleSoapClient('http://localhost:8080/axis2/services/Version2?wsdl', $this->options); - $soapKernel = $sc->getSoapKernel(); - $wsaFilter = new BeSimpleWsAddressingFilter(); - $soapKernel->registerFilter($wsaFilter); - - $wsaFilter->setReplyTo(BeSimpleWsAddressingFilter::ENDPOINT_REFERENCE_ANONYMOUS); - $wsaFilter->setMessageId(); - - $version = $sc->getVersion(); - - $soapSessionId1 = $wsaFilter->getReferenceParameter('http://ws.apache.org/namespaces/axis2', 'ServiceGroupId'); - - $wsaFilter->addReferenceParameter('http://ws.apache.org/namespaces/axis2', 'axis2', 'ServiceGroupId', $soapSessionId1); - - $version = $sc->getVersion(); - - $soapSessionId2 = $wsaFilter->getReferenceParameter('http://ws.apache.org/namespaces/axis2', 'ServiceGroupId'); - - $this->assertEquals($soapSessionId1, $soapSessionId2); - } -} diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/WsSecuritySigEncAxisInteropTest.php b/src/BeSimple/SoapClient/Tests/AxisInterop/WsSecuritySigEncAxisInteropTest.php deleted file mode 100644 index 2d7070e..0000000 --- a/src/BeSimple/SoapClient/Tests/AxisInterop/WsSecuritySigEncAxisInteropTest.php +++ /dev/null @@ -1,107 +0,0 @@ - SOAP_1_2, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'classmap' => array( - 'getBook' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBook', - 'getBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBookResponse', - 'getBooksByType' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBooksByType', - 'getBooksByTypeResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBooksByTypeResponse', - 'addBook' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBook', - 'addBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBookResponse', - 'BookInformation' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation', - ), - 'proxy_host' => false, - ); - - public function testSigEnc() - { - $sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecuritySigEnc.wsdl', $this->options); - - $wssFilter = new BeSimpleWsSecurityFilter(); - // user key for signature and encryption - $securityKeyUser = new BeSimpleWsSecurityKey(); - $securityKeyUser->addPrivateKey(XmlSecurityKey::RSA_SHA1, __DIR__.'/Fixtures/clientkey.pem', true); - $securityKeyUser->addPublicKey(XmlSecurityKey::RSA_SHA1, __DIR__.'/Fixtures/clientcert.pem', true); - $wssFilter->setUserSecurityKeyObject($securityKeyUser); - // service key for encryption - $securityKeyService = new BeSimpleWsSecurityKey(); - $securityKeyService->addPrivateKey(XmlSecurityKey::TRIPLEDES_CBC); - $securityKeyService->addPublicKey(XmlSecurityKey::RSA_1_5, __DIR__.'/Fixtures/servercert.pem', true); - $wssFilter->setServiceSecurityKeyObject($securityKeyService); - // TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | TOKEN_REFERENCE_SECURITY_TOKEN | TOKEN_REFERENCE_THUMBPRINT_SHA1 - $wssFilter->setSecurityOptionsSignature(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_SECURITY_TOKEN); - $wssFilter->setSecurityOptionsEncryption(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_THUMBPRINT_SHA1); - - $soapKernel = $sc->getSoapKernel(); - $soapKernel->registerFilter($wssFilter); - - $gb = new getBook(); - $gb->isbn = '0061020052'; - $result = $sc->getBook($gb); - $this->assertInstanceOf('BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation', $result->getBookReturn); - - $ab = new addBook(); - $ab->isbn = '0445203498'; - $ab->title = 'The Dragon Never Sleeps'; - $ab->author = 'Cook, Glen'; - $ab->type = 'scifi'; - - $this->assertTrue((bool) $sc->addBook($ab)); - - // getBooksByType("scifi"); - } -} diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/WsSecurityUserPassAxisInteropTest.php b/src/BeSimple/SoapClient/Tests/AxisInterop/WsSecurityUserPassAxisInteropTest.php deleted file mode 100644 index 2ee71d6..0000000 --- a/src/BeSimple/SoapClient/Tests/AxisInterop/WsSecurityUserPassAxisInteropTest.php +++ /dev/null @@ -1,97 +0,0 @@ - SOAP_1_2, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'classmap' => array( - 'getBook' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBook', - 'getBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBookResponse', - 'getBooksByType' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBooksByType', - 'getBooksByTypeResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\getBooksByTypeResponse', - 'addBook' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBook', - 'addBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBookResponse', - 'BookInformation' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation', - ), - 'proxy_host' => false, - ); - - public function testUserPassText() - { - $sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $this->options); - - $wssFilter = new BeSimpleWsSecurityFilter(true, 600); - $wssFilter->addUserData('libuser', 'books', BeSimpleWsSecurityFilter::PASSWORD_TYPE_TEXT); - - $soapKernel = $sc->getSoapKernel(); - $soapKernel->registerFilter($wssFilter); - - $gb = new getBook(); - $gb->isbn = '0061020052'; - $result = $sc->getBook($gb); - $this->assertInstanceOf('BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation', $result->getBookReturn); - - $ab = new addBook(); - $ab->isbn = '0445203498'; - $ab->title = 'The Dragon Never Sleeps'; - $ab->author = 'Cook, Glen'; - $ab->type = 'scifi'; - - $this->assertTrue((bool) $sc->addBook($ab)); - - // getBooksByType("scifi"); - } - - public function testUserPassDigest() - { - $sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $this->options); - - $wssFilter = new BeSimpleWsSecurityFilter(true, 600); - $wssFilter->addUserData( 'libuser', 'books', BeSimpleWsSecurityFilter::PASSWORD_TYPE_DIGEST ); - - $soapKernel = $sc->getSoapKernel(); - $soapKernel->registerFilter($wssFilter); - - $gb = new getBook(); - $gb->isbn = '0061020052'; - $result = $sc->getBook($gb); - $this->assertInstanceOf('BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation', $result->getBookReturn); - - $ab = new addBook(); - $ab->isbn = '0445203498'; - $ab->title = 'The Dragon Never Sleeps'; - $ab->author = 'Cook, Glen'; - $ab->type = 'scifi'; - - $this->assertTrue((bool) $sc->addBook($ab)); - - // getBooksByType("scifi"); - } -} diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/besimple-swa.aar b/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/besimple-swa.aar deleted file mode 100644 index bb41750..0000000 Binary files a/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/besimple-swa.aar and /dev/null differ diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/library-signencr.aar b/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/library-signencr.aar deleted file mode 100644 index 25ffc2d..0000000 Binary files a/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/library-signencr.aar and /dev/null differ diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/library-username-digest.aar b/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/library-username-digest.aar deleted file mode 100644 index f6f8595..0000000 Binary files a/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/library-username-digest.aar and /dev/null differ diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/sample-mtom.aar b/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/sample-mtom.aar deleted file mode 100644 index a215edc..0000000 Binary files a/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/sample-mtom.aar and /dev/null differ diff --git a/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/version2.aar b/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/version2.aar deleted file mode 100644 index df76662..0000000 Binary files a/src/BeSimple/SoapClient/Tests/AxisInterop/axis_services/version2.aar and /dev/null differ diff --git a/src/BeSimple/SoapClient/Tests/CurlTest.php b/src/BeSimple/SoapClient/Tests/CurlTest.php deleted file mode 100644 index be8a80f..0000000 --- a/src/BeSimple/SoapClient/Tests/CurlTest.php +++ /dev/null @@ -1,86 +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. - */ - -namespace BeSimple\SoapClient\Tests; - -use BeSimple\SoapClient\Curl\Curl; -use BeSimple\SoapClient\Curl\CurlOptionsBuilder; - -/** - * @author Andreas Schamberger - */ -class CurlTest extends AbstractWebserverTest -{ - public function testExec() - { - $curlOptions = CurlOptionsBuilder::buildDefault(); - $curl = new Curl( - $curlOptions - ); - - $this->assertTrue($curl->executeCurl($curlOptions, sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT))); - $this->assertTrue($curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT))); - } - - public function testGetErrorMessage() - { - $curl = new Curl(array( - 'proxy_host' => false, - )); - - $curl->exec('http://unknown/curl.txt'); - $this->assertEquals('Could not connect to host', $curl->getErrorMessage()); - - $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()); - } - - public function testGetRequestHeaders() - { - $curl = new Curl(array( - 'proxy_host' => false, - )); - - $curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)); - $this->assertEquals(132 + self::$websererPortLength, strlen($curl->getRequestHeaders())); - - $curl->exec(sprintf('http://localhost:%s/404.txt', WEBSERVER_PORT)); - $this->assertEquals(131 + self::$websererPortLength, strlen($curl->getRequestHeaders())); - } - - public function testGetResponse() - { - $curl = new Curl(array( - 'proxy_host' => false, - )); - - $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(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT)); - $this->assertSame('Not Found', $curl->getResponseStatusMessage()); - } - - public function testGetResponseBody() - { - $curl = new Curl(array( - 'proxy_host' => false, - )); - - $curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)); - $this->assertEquals('This is a testfile for cURL.', $curl->getResponseBody()); - } -} diff --git a/src/BeSimple/SoapClient/Tests/Fixtures/curl.txt b/src/BeSimple/SoapClient/Tests/Fixtures/curl.txt deleted file mode 100644 index 070def3..0000000 --- a/src/BeSimple/SoapClient/Tests/Fixtures/curl.txt +++ /dev/null @@ -1 +0,0 @@ -This is a testfile for cURL. \ No newline at end of file diff --git a/src/BeSimple/SoapClient/Tests/Fixtures/foobar.wsdl b/src/BeSimple/SoapClient/Tests/Fixtures/foobar.wsdl deleted file mode 100644 index a890dd8..0000000 --- a/src/BeSimple/SoapClient/Tests/Fixtures/foobar.wsdl +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/BeSimple/SoapClient/Tests/Fixtures/type_include.xsd b/src/BeSimple/SoapClient/Tests/Fixtures/type_include.xsd deleted file mode 100644 index a41dd9a..0000000 --- a/src/BeSimple/SoapClient/Tests/Fixtures/type_include.xsd +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/BeSimple/SoapClient/Tests/Fixtures/wsdl_include.wsdl b/src/BeSimple/SoapClient/Tests/Fixtures/wsdl_include.wsdl deleted file mode 100644 index 775240a..0000000 --- a/src/BeSimple/SoapClient/Tests/Fixtures/wsdl_include.wsdl +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/BeSimple/SoapClient/Tests/Fixtures/wsdlinclude/wsdlinctest_absolute.xml b/src/BeSimple/SoapClient/Tests/Fixtures/wsdlinclude/wsdlinctest_absolute.xml deleted file mode 100644 index 2f59ba1..0000000 --- a/src/BeSimple/SoapClient/Tests/Fixtures/wsdlinclude/wsdlinctest_absolute.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - wsdlincludetest - - diff --git a/src/BeSimple/SoapClient/Tests/Fixtures/wsdlinclude/wsdlinctest_relative.xml b/src/BeSimple/SoapClient/Tests/Fixtures/wsdlinclude/wsdlinctest_relative.xml deleted file mode 100644 index 8148e60..0000000 --- a/src/BeSimple/SoapClient/Tests/Fixtures/wsdlinclude/wsdlinctest_relative.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - wsdlincludetest - - diff --git a/src/BeSimple/SoapClient/Tests/Fixtures/xsdinclude/xsdinctest_absolute.xml b/src/BeSimple/SoapClient/Tests/Fixtures/xsdinclude/xsdinctest_absolute.xml deleted file mode 100644 index 166e549..0000000 --- a/src/BeSimple/SoapClient/Tests/Fixtures/xsdinclude/xsdinctest_absolute.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - xsdinctest - - - - - - diff --git a/src/BeSimple/SoapClient/Tests/Fixtures/xsdinclude/xsdinctest_relative.xml b/src/BeSimple/SoapClient/Tests/Fixtures/xsdinclude/xsdinctest_relative.xml deleted file mode 100644 index 58cea74..0000000 --- a/src/BeSimple/SoapClient/Tests/Fixtures/xsdinclude/xsdinctest_relative.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - xsdinctest - - - - - - diff --git a/src/BeSimple/SoapClient/Tests/Mock/.readme b/src/BeSimple/SoapClient/Tests/Mock/.readme deleted file mode 100644 index a58a137..0000000 --- a/src/BeSimple/SoapClient/Tests/Mock/.readme +++ /dev/null @@ -1,23 +0,0 @@ -# HOW TO PREPARE Mock SWA Service - -1. Create an test endpoint by using tools such as mockable.io, that will return response (expect POST requests with SOAP v1.1) -similar to the one provided in example file src/BeSimple/SoapClient/Tests/Mock/MockSwaService.example.response -and Content-Type headers from src/BeSimple/SoapClient/Tests/Mock/MockSwaService.example.response.headers - -Example Endpoint URL: https://demo0580999.mockable.io/soap/testGenerator - -2. Create a test WSDL endpoint that will return WSDL file from (expect GET requests) -an example file src/BeSimple/SoapClient/Tests/Mock/MockSwaService.wsdl - -Example WSDL endpoint URL: https://demo0580999.mockable.io/soap/testGenerator?WSDL - -3. Take the two endpoints and configure SoapClientBuilderTest::TEST_ENDPOINT_SWA -and SoapClientBuilderTest::TEST_REMOTE_WSDL_SWA variables - -4. The test BeSimple\SoapClient\Tests\SoapClientBuilderTest::testSoapCallSwaWithAttachmentsOnResponse should work correctly. - -If not, try to catch SoapFaultWithTracingData thrown by the soapCall method: - -$soapClient->soapCall('generateTest', [$generateTestRequest]); - -You can print the SoapFaultWithTracingData attributes in order to investigate the SoapClient request and request headers. \ No newline at end of file diff --git a/src/BeSimple/SoapClient/Tests/Mock/MockSwaService.example.response b/src/BeSimple/SoapClient/Tests/Mock/MockSwaService.example.response deleted file mode 100644 index a96157d..0000000 --- a/src/BeSimple/SoapClient/Tests/Mock/MockSwaService.example.response +++ /dev/null @@ -1,18 +0,0 @@ - ---Part_13_58a1b01a466a6.58a1b01a466e8 -Content-Type: application/soap+xml; charset=utf-8 -Content-Transfer-Encoding: 8bit -Content-ID: - - -generateTestReturndummy-attachment.txt - ---Part_13_58a1b01a466a6.58a1b01a466e8 -Content-Type: text/plain; charset=utf-8 -Content-Transfer-Encoding: 8bit -Content-ID: -Content-Location: dummy-attachment.txt - -Hello world! - ---Part_13_58a1b01a466a6.58a1b01a466e8-- diff --git a/src/BeSimple/SoapClient/Tests/Mock/MockSwaService.example.response.headers b/src/BeSimple/SoapClient/Tests/Mock/MockSwaService.example.response.headers deleted file mode 100644 index f73280d..0000000 --- a/src/BeSimple/SoapClient/Tests/Mock/MockSwaService.example.response.headers +++ /dev/null @@ -1 +0,0 @@ -multipart/related; type="application/soap+xml"; charset=utf-8; boundary=Part_13_58a1b01a466a6.58a1b01a466e8; start="" diff --git a/src/BeSimple/SoapClient/Tests/Mock/MockSwaService.wsdl b/src/BeSimple/SoapClient/Tests/Mock/MockSwaService.wsdl deleted file mode 100644 index 045b318..0000000 --- a/src/BeSimple/SoapClient/Tests/Mock/MockSwaService.wsdl +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - User name for authorization - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - WSDL file for TestGeneratorService - - - - - diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/AttachmentRequest.php b/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/AttachmentRequest.php deleted file mode 100644 index 8be17dc..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/AttachmentRequest.php +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/SwA.wsdl b/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/SwA.wsdl deleted file mode 100644 index 46b14b7..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/SwA.wsdl +++ /dev/null @@ -1,162 +0,0 @@ - - - BeSimpleSwaService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/WsSecuritySigEnc.wsdl b/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/WsSecuritySigEnc.wsdl deleted file mode 100644 index d329f1f..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/WsSecuritySigEnc.wsdl +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/WsSecurityUserPass.wsdl b/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/WsSecurityUserPass.wsdl deleted file mode 100644 index 7d4b33f..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/WsSecurityUserPass.wsdl +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/addBook.php b/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/addBook.php deleted file mode 100644 index 8d22133..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/Fixtures/addBook.php +++ /dev/null @@ -1,11 +0,0 @@ - SOAP_1_1, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'trace' => true, // enables use of the methods SoapClient->__getLastRequest, SoapClient->__getLastRequestHeaders, SoapClient->__getLastResponse and SoapClient->__getLastResponseHeaders - 'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_MTOM, - 'cache_wsdl' => WSDL_CACHE_NONE, - 'classmap' => array( - 'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary', - 'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest', - ), - 'connection_timeout' => 1, -); - -$sc = new BeSimpleSoapClient('Fixtures/MTOM.wsdl', $options); - -//var_dump($sc->__getFunctions()); -//var_dump($sc->__getTypes()); - -try { - $b64 = new base64Binary(); - $b64->_ = 'This is a test. :)'; - $b64->contentType = 'text/plain'; - - $attachment = new AttachmentRequest(); - $attachment->fileName = 'test123.txt'; - $attachment->binaryData = $b64; - - var_dump($sc->attachment($attachment)); - -} catch (Exception $e) { - var_dump($e); -} - -// var_dump( -// $sc->__getLastRequestHeaders(), -// $sc->__getLastRequest(), -// $sc->__getLastResponseHeaders(), -// $sc->__getLastResponse() -// ); \ No newline at end of file diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/MTOMServer.php b/src/BeSimple/SoapClient/Tests/ServerInterop/MTOMServer.php deleted file mode 100644 index 72e8e19..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/MTOMServer.php +++ /dev/null @@ -1,35 +0,0 @@ - SOAP_1_1, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_MTOM, - 'cache_wsdl' => WSDL_CACHE_NONE, - 'classmap' => array( - 'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary', - 'AttachmentType' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest', - ), -); - -class Mtom -{ - public function attachment(Fixtures\AttachmentRequest $attachment) - { - $b64 = $attachment->binaryData; - - file_put_contents(__DIR__.'/'.$attachment->fileName, $b64->_); - - return 'File saved succesfully.'; - } -} - -$ss = new BeSimpleSoapServer(__DIR__.'/Fixtures/MTOM.wsdl', $options); -$ss->setClass('Mtom'); -$ss->handle(); diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/MtomServerInteropTest.php b/src/BeSimple/SoapClient/Tests/ServerInterop/MtomServerInteropTest.php deleted file mode 100644 index 07d7b48..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/MtomServerInteropTest.php +++ /dev/null @@ -1,44 +0,0 @@ - SOAP_1_1, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_MTOM, - 'cache_wsdl' => WSDL_CACHE_NONE, - 'classmap' => array( - 'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary', - 'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest', - ), - 'proxy_host' => false, - ); - - public function testAttachment() - { - $sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/MTOM.wsdl', $this->options); - - $b64 = new base64Binary(); - $b64->_ = 'This is a test. :)'; - $b64->contentType = 'text/plain'; - - $attachment = new AttachmentRequest(); - $attachment->fileName = 'test123.txt'; - $attachment->binaryData = $b64; - - $this->assertEquals('File saved succesfully.', $sc->attachment($attachment)); - - $fileCreatedByServer = __DIR__.'/'.$attachment->fileName; - $this->assertEquals($b64->_, file_get_contents($fileCreatedByServer)); - unlink($fileCreatedByServer); - } -} diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/SwAServer.php b/src/BeSimple/SoapClient/Tests/ServerInterop/SwAServer.php deleted file mode 100644 index 337a0a0..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/SwAServer.php +++ /dev/null @@ -1,49 +0,0 @@ - SOAP_1_1, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_SWA, - 'cache_wsdl' => WSDL_CACHE_NONE, - 'classmap' => array( - 'downloadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\downloadFile', - 'downloadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\downloadFileResponse', - 'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile', - 'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse', - ), -); - -class SwA -{ - public function uploadFile(uploadFile $uploadFile) - { - file_put_contents(__DIR__.'/'.$uploadFile->name, $uploadFile->data); - - $ufr = new uploadFileResponse(); - $ufr->return = 'File saved succesfully.'; - - return $ufr; - } - - public function downloadFile(downloadFile $downloadFile) - { - $dfr = new downloadFileResponse(); - $dfr->data = file_get_contents(__DIR__.'/'.$downloadFile->name); - - return $dfr; - } -} - -$ss = new BeSimpleSoapServer(__DIR__.'/Fixtures/SwA.wsdl', $options); -$ss->setClass('SwA'); -$ss->handle(); diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/SwaClient.php b/src/BeSimple/SoapClient/Tests/ServerInterop/SwaClient.php deleted file mode 100644 index 96f34fd..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/SwaClient.php +++ /dev/null @@ -1,52 +0,0 @@ - SOAP_1_1, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_SWA, - 'cache_wsdl' => WSDL_CACHE_NONE, - 'trace' => true, // enables use of the methods SoapClient->__getLastRequest, SoapClient->__getLastRequestHeaders, SoapClient->__getLastResponse and SoapClient->__getLastResponseHeaders - 'classmap' => array( - 'downloadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\downloadFile', - 'downloadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\downloadFileResponse', - 'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile', - 'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse', - ), -); - -$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $options); - -try { - - $upload = new uploadFile(); - $upload->name = 'upload.txt'; - $upload->data = 'This is a test. :)'; - $result = $sc->uploadFile($upload); - - var_dump($result); - - $download = new downloadFile(); - $download->name = 'upload.txt'; - var_dump($sc->downloadFile($download)); -} catch (Exception $e) { - var_dump($e); -} - -// var_dump( -// $sc->__getLastRequestHeaders(), -// $sc->__getLastRequest(), -// $sc->__getLastResponseHeaders(), -// $sc->__getLastResponse() -// ); \ No newline at end of file diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/SwaServerInteropTest.php b/src/BeSimple/SoapClient/Tests/ServerInterop/SwaServerInteropTest.php deleted file mode 100644 index 01eaeae..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/SwaServerInteropTest.php +++ /dev/null @@ -1,68 +0,0 @@ - SOAP_1_1, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'attachment_type' => BeSimpleSoapHelper::ATTACHMENTS_TYPE_SWA, - 'cache_wsdl' => WSDL_CACHE_NONE, - 'classmap' => array( - 'downloadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\downloadFile', - 'downloadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\downloadFileResponse', - 'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile', - 'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse', - ), - 'proxy_host' => false, - ); - - public function testUploadDownloadText() - { - $sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $this->options); - - $upload = new uploadFile(); - $upload->name = 'upload.txt'; - $upload->data = 'This is a test. :)'; - $result = $sc->uploadFile($upload); - - $this->assertEquals('File saved succesfully.', $result->return); - - $download = new downloadFile(); - $download->name = 'upload.txt'; - $result = $sc->downloadFile($download); - - $this->assertEquals($upload->data, $result->data); - - unlink(__DIR__.'/../ServerInterop/'.$download->name); - } - - public function testUploadDownloadImage() - { - $sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $this->options); - - $upload = new uploadFile(); - $upload->name = 'image.jpg'; - $upload->data = file_get_contents(__DIR__.'/Fixtures/image.jpg'); // source: http://www.freeimageslive.com/galleries/light/pics/swirl3768.jpg; - $result = $sc->uploadFile($upload); - - $this->assertEquals('File saved succesfully.', $result->return); - - $download = new downloadFile(); - $download->name = 'image.jpg'; - $result = $sc->downloadFile($download); - - $this->assertEquals($upload->data, $result->data); - - unlink(__DIR__.'/../ServerInterop/'.$download->name); - } -} diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/TestCase.php b/src/BeSimple/SoapClient/Tests/ServerInterop/TestCase.php deleted file mode 100644 index b0f1f40..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/TestCase.php +++ /dev/null @@ -1,29 +0,0 @@ -markTestSkipped( - 'The PHP cli webserver is not available with PHP 5.3.' - ); - } - - $ch = curl_init('http://localhost:8081/'); - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); - curl_setopt($ch, CURLOPT_HEADER, true); - curl_setopt($ch, CURLOPT_NOBODY, true); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - - if (curl_exec($ch) === false) { - $this->markTestSkipped( - 'The PHP webserver is not started on port 8081.' - ); - } - - curl_close($ch); - } -} \ No newline at end of file diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServer.php b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServer.php deleted file mode 100644 index c8b01c6..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServer.php +++ /dev/null @@ -1,82 +0,0 @@ - SOAP_1_1, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'cache_wsdl' => WSDL_CACHE_NONE, - 'classmap' => array( - 'getBook' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBook', - 'getBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBookResponse', - 'getBooksByType' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBooksByType', - 'getBooksByTypeResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBooksByTypeResponse', - 'addBook' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBook', - 'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse', - 'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation', - ), -); - -class WsSecuritySigEncServer -{ - public function getBook(getBook $gb) - { - $bi = new BookInformation(); - $bi->isbn = $gb->isbn; - $bi->title = 'title'; - $bi->author = 'author'; - $bi->type = 'scifi'; - - $br = new getBookResponse(); - $br->getBookReturn = $bi; - - return $br; - } - - public function addBook(addBook $ab) - { - $abr = new addBookResponse(); - $abr->addBookReturn = true; - - return $abr; - } -} - -$ss = new BeSimpleSoapServer(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $options); - -$wssFilter = new BeSimpleWsSecurityFilter(); - -// user key for signature and encryption -$securityKeyUser = new BeSimpleWsSecurityKey(); -$securityKeyUser->addPrivateKey(XmlSecurityKey::RSA_SHA1, __DIR__.'/Fixtures/serverkey.pem', true); -$securityKeyUser->addPublicKey(XmlSecurityKey::RSA_SHA1, __DIR__.'/Fixtures/servercert.pem', true); -$wssFilter->setUserSecurityKeyObject($securityKeyUser); -// service key for encryption -$securityKeyService = new BeSimpleWsSecurityKey(); -$securityKeyService->addPrivateKey(XmlSecurityKey::TRIPLEDES_CBC); -$securityKeyService->addPublicKey(XmlSecurityKey::RSA_1_5, __DIR__.'/Fixtures/clientcert.pem', true); -$wssFilter->setServiceSecurityKeyObject($securityKeyService); -// TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | TOKEN_REFERENCE_SECURITY_TOKEN | TOKEN_REFERENCE_THUMBPRINT_SHA1 -$wssFilter->setSecurityOptionsSignature(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_SECURITY_TOKEN); -$wssFilter->setSecurityOptionsEncryption(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_THUMBPRINT_SHA1); - -$soapKernel = $ss->getSoapKernel(); -$soapKernel->registerFilter($wssFilter); - -$ss->setClass('WsSecuritySigEncServer'); -$ss->handle(); diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerClient.php b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerClient.php deleted file mode 100644 index 1d529d6..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerClient.php +++ /dev/null @@ -1,82 +0,0 @@ - SOAP_1_2, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'trace' => true, // enables use of the methods SoapClient->__getLastRequest, SoapClient->__getLastRequestHeaders, SoapClient->__getLastResponse and SoapClient->__getLastResponseHeaders - 'classmap' => array( - 'getBook' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBook', - 'getBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBookResponse', - 'getBooksByType' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBooksByType', - 'getBooksByTypeResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBooksByTypeResponse', - 'addBook' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBook', - 'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse', - 'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation', - ), -); - -$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecuritySigEnc.wsdl', $options); - -//var_dump($sc->__getFunctions()); -//var_dump($sc->__getTypes()); - -try { - $wssFilter = new BeSimpleWsSecurityFilter(); - // user key for signature and encryption - $securityKeyUser = new BeSimpleWsSecurityKey(); - $securityKeyUser->addPrivateKey(XmlSecurityKey::RSA_SHA1, __DIR__.'/Fixtures/clientkey.pem', true); - $securityKeyUser->addPublicKey(XmlSecurityKey::RSA_SHA1, __DIR__.'/Fixtures/clientcert.pem', true); - $wssFilter->setUserSecurityKeyObject($securityKeyUser); - // service key for encryption - $securityKeyService = new BeSimpleWsSecurityKey(); - $securityKeyService->addPrivateKey(XmlSecurityKey::TRIPLEDES_CBC); - $securityKeyService->addPublicKey(XmlSecurityKey::RSA_1_5, __DIR__.'/Fixtures/servercert.pem', true); - $wssFilter->setServiceSecurityKeyObject($securityKeyService); - // TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | TOKEN_REFERENCE_SECURITY_TOKEN | TOKEN_REFERENCE_THUMBPRINT_SHA1 - $wssFilter->setSecurityOptionsSignature(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_SECURITY_TOKEN); - $wssFilter->setSecurityOptionsEncryption(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_THUMBPRINT_SHA1); - - $soapKernel = $sc->getSoapKernel(); - $soapKernel->registerFilter($wssFilter); - - $gb = new getBook(); - $gb->isbn = '0061020052'; - $result = $sc->getBook($gb); - var_dump($result->getBookReturn); - - $ab = new addBook(); - $ab->isbn = '0445203498'; - $ab->title = 'The Dragon Never Sleeps'; - $ab->author = 'Cook, Glen'; - $ab->type = 'scifi'; - - var_dump($sc->addBook($ab)); - -} catch (Exception $e) { - var_dump($e); -} - -// var_dump( -// $sc->__getLastRequestHeaders(), -// $sc->__getLastRequest(), -// $sc->__getLastResponseHeaders(), -// $sc->__getLastResponse() -// ); diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerInteropTest.php b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerInteropTest.php deleted file mode 100644 index 8978fd6..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecuritySigEncServerInteropTest.php +++ /dev/null @@ -1,73 +0,0 @@ - SOAP_1_2, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'classmap' => array( - 'getBook' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBook', - 'getBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBookResponse', - 'getBooksByType' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBooksByType', - 'getBooksByTypeResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBooksByTypeResponse', - 'addBook' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBook', - 'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse', - 'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation', - ), - 'proxy_host' => false, - ); - - public function testSigEnc() - { - $sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecuritySigEnc.wsdl', $this->options); - - $wssFilter = new BeSimpleWsSecurityFilter(); - // user key for signature and encryption - $securityKeyUser = new BeSimpleWsSecurityKey(); - $securityKeyUser->addPrivateKey(XmlSecurityKey::RSA_SHA1, __DIR__.'/Fixtures/clientkey.pem', true); - $securityKeyUser->addPublicKey(XmlSecurityKey::RSA_SHA1, __DIR__.'/Fixtures/clientcert.pem', true); - $wssFilter->setUserSecurityKeyObject($securityKeyUser); - // service key for encryption - $securityKeyService = new BeSimpleWsSecurityKey(); - $securityKeyService->addPrivateKey(XmlSecurityKey::TRIPLEDES_CBC); - $securityKeyService->addPublicKey(XmlSecurityKey::RSA_1_5, __DIR__.'/Fixtures/servercert.pem', true); - $wssFilter->setServiceSecurityKeyObject($securityKeyService); - // TOKEN_REFERENCE_SUBJECT_KEY_IDENTIFIER | TOKEN_REFERENCE_SECURITY_TOKEN | TOKEN_REFERENCE_THUMBPRINT_SHA1 - $wssFilter->setSecurityOptionsSignature(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_SECURITY_TOKEN); - $wssFilter->setSecurityOptionsEncryption(BeSimpleWsSecurityFilter::TOKEN_REFERENCE_THUMBPRINT_SHA1); - - $soapKernel = $sc->getSoapKernel(); - $soapKernel->registerFilter($wssFilter); - - $gb = new getBook(); - $gb->isbn = '0061020052'; - $result = $sc->getBook($gb); - $this->assertInstanceOf('BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation', $result->getBookReturn); - - $ab = new addBook(); - $ab->isbn = '0445203498'; - $ab->title = 'The Dragon Never Sleeps'; - $ab->author = 'Cook, Glen'; - $ab->type = 'scifi'; - - $this->assertTrue((bool) $sc->addBook($ab)); - - // getBooksByType("scifi"); - } -} diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServer.php b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServer.php deleted file mode 100644 index 8a2e2dc..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServer.php +++ /dev/null @@ -1,78 +0,0 @@ - SOAP_1_1, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'cache_wsdl' => WSDL_CACHE_NONE, - 'classmap' => array( - 'getBook' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBook', - 'getBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBookResponse', - 'getBooksByType' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBooksByType', - 'getBooksByTypeResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBooksByTypeResponse', - 'addBook' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBook', - 'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse', - 'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation', - ), -); - -class Auth -{ - public static function usernamePasswordCallback($user) - { - if ($user == 'libuser') { - return 'books'; - } - - return null; - } -} - -class WsSecurityUserPassServer -{ - public function getBook(getBook $gb) - { - $bi = new BookInformation(); - $bi->isbn = $gb->isbn; - $bi->title = 'title'; - $bi->author = 'author'; - $bi->type = 'scifi'; - - $br = new getBookResponse(); - $br->getBookReturn = $bi; - - return $br; - } - - public function addBook(addBook $ab) - { - $abr = new addBookResponse(); - $abr->addBookReturn = true; - - return $abr; - } -} - -$ss = new BeSimpleSoapServer(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $options); - -$wssFilter = new BeSimpleWsSecurityFilter(); -$wssFilter->setUsernamePasswordCallback(array('Auth', 'usernamePasswordCallback')); - -$soapKernel = $ss->getSoapKernel(); -$soapKernel->registerFilter($wssFilter); - -$ss->setClass('WsSecurityUserPassServer'); -$ss->handle(); diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerClient.php b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerClient.php deleted file mode 100644 index 90cf534..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerClient.php +++ /dev/null @@ -1,67 +0,0 @@ - SOAP_1_2, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'trace' => true, // enables use of the methods SoapClient->__getLastRequest, SoapClient->__getLastRequestHeaders, SoapClient->__getLastResponse and SoapClient->__getLastResponseHeaders - 'classmap' => array( - 'getBook' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBook', - 'getBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBookResponse', - 'getBooksByType' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBooksByType', - 'getBooksByTypeResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBooksByTypeResponse', - 'addBook' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBook', - 'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse', - 'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation', - ), -); - -$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $options); - -//var_dump($sc->__getFunctions()); -//var_dump($sc->__getTypes()); - -try { - $wssFilter = new BeSimpleWsSecurityFilter(true, 600); - $wssFilter->addUserData('libuser', 'books', BeSimpleWsSecurityFilter::PASSWORD_TYPE_DIGEST); - - $soapKernel = $sc->getSoapKernel(); - $soapKernel->registerFilter($wssFilter); - - $gb = new getBook(); - $gb->isbn = '0061020052'; - $result = $sc->getBook($gb); - var_dump($result->getBookReturn); - - $ab = new addBook(); - $ab->isbn = '0445203498'; - $ab->title = 'The Dragon Never Sleeps'; - $ab->author = 'Cook, Glen'; - $ab->type = 'scifi'; - - var_dump($sc->addBook($ab)); - -} catch (Exception $e) { - var_dump($e); -} - -// var_dump( -// $sc->__getLastRequestHeaders(), -// $sc->__getLastRequest(), -// $sc->__getLastResponseHeaders(), -// $sc->__getLastResponse() -// ); diff --git a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerInteropTest.php b/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerInteropTest.php deleted file mode 100644 index efe86b5..0000000 --- a/src/BeSimple/SoapClient/Tests/ServerInterop/WsSecurityUserPassServerInteropTest.php +++ /dev/null @@ -1,86 +0,0 @@ - SOAP_1_2, - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1 - 'classmap' => array( - 'getBook' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBook', - 'getBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBookResponse', - 'getBooksByType' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBooksByType', - 'getBooksByTypeResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\getBooksByTypeResponse', - 'addBook' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBook', - 'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse', - 'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation', - ), - 'proxy_host' => false, - ); - - public function testUserPassText() - { - $sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $this->options); - - $wssFilter = new BeSimpleWsSecurityFilter(true, 600); - $wssFilter->addUserData('libuser', 'books', BeSimpleWsSecurityFilter::PASSWORD_TYPE_TEXT); - - $soapKernel = $sc->getSoapKernel(); - $soapKernel->registerFilter($wssFilter); - - $gb = new getBook(); - $gb->isbn = '0061020052'; - $result = $sc->getBook($gb); - $this->assertInstanceOf('BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation', $result->getBookReturn); - - $ab = new addBook(); - $ab->isbn = '0445203498'; - $ab->title = 'The Dragon Never Sleeps'; - $ab->author = 'Cook, Glen'; - $ab->type = 'scifi'; - - $this->assertTrue((bool) $sc->addBook($ab)); - - // getBooksByType("scifi"); - } - - public function testUserPassDigest() - { - $sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $this->options); - - $wssFilter = new BeSimpleWsSecurityFilter(true, 600); - $wssFilter->addUserData( 'libuser', 'books', BeSimpleWsSecurityFilter::PASSWORD_TYPE_DIGEST ); - - $soapKernel = $sc->getSoapKernel(); - $soapKernel->registerFilter($wssFilter); - - $gb = new getBook(); - $gb->isbn = '0061020052'; - $result = $sc->getBook($gb); - $this->assertInstanceOf('BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation', $result->getBookReturn); - - $ab = new addBook(); - $ab->isbn = '0445203498'; - $ab->title = 'The Dragon Never Sleeps'; - $ab->author = 'Cook, Glen'; - $ab->type = 'scifi'; - - $this->assertTrue((bool) $sc->addBook($ab)); - - // getBooksByType("scifi"); - } -} diff --git a/src/BeSimple/SoapClient/Tests/WsdlDownloaderTest.php b/src/BeSimple/SoapClient/Tests/WsdlDownloaderTest.php deleted file mode 100644 index a5e4595..0000000 --- a/src/BeSimple/SoapClient/Tests/WsdlDownloaderTest.php +++ /dev/null @@ -1,291 +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. - */ - -namespace BeSimple\SoapClient\Tests; - -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; - -/** - * @author Andreas Schamberger - * @author Francis Besset - */ -class WsdlDownloaderTest extends AbstractWebserverTest -{ - static protected $filesystem; - - static protected $fixturesPath; - - /** - * @dataProvider provideDownload - */ - public function testDownload($source, $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(array( - 'proxy_host' => false, - ))); - $this->assertCount(0, $wsdlCacheDir->getChildren()); - - $cacheFileName = $wsdlDownloader->download($source); - $this->assertCount($nbDownloads, $wsdlCacheDir->getChildren()); - - $this->assertRegExp('#'.sprintf($regexp, $cacheDirForRegExp).'#', file_get_contents($cacheFileName)); - } - - public function provideDownload() - { - return array( - array( - __DIR__.DIRECTORY_SEPARATOR.'Fixtures/build_include/xsdinctest_absolute.xml', - '%s/wsdl_[a-f0-9]{32}\.cache', - 2, - ), - array( - __DIR__.DIRECTORY_SEPARATOR.'Fixtures/xsdinclude/xsdinctest_relative.xml', - '\.\./type_include\.xsd', - 1, - ), - array( - sprintf('http://localhost:%d/build_include/xsdinctest_absolute.xml', WEBSERVER_PORT), - '%s/wsdl_[a-f0-9]{32}\.cache', - 2, - ), - array( - sprintf('http://localhost:%d/xsdinclude/xsdinctest_relative.xml', WEBSERVER_PORT), - '%s/wsdl_[a-f0-9]{32}\.cache', - 2, - ), - ); - } - - public function testIsRemoteFile() - { - $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')); - } - - /** - * @dataProvider provideResolveWsdlIncludes - */ - public function testResolveWsdlIncludes($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(array( - 'proxy_host' => false, - ))); - $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/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/build_include/wsdlinctest_absolute.xml', - '%s/cache_local_absolute.xml', - null, - '%s/wsdl_[a-f0-9]{32}.cache', - 2, - ), - array( - __DIR__.DIRECTORY_SEPARATOR.'Fixtures/wsdlinclude/wsdlinctest_relative.xml', - '%s/cache_local_relative.xml', - null, - '\.\./wsdl_include\.wsdl', - 1, - ), - array( - $remoteUrlAbsolute, - '%s/cache_remote_absolute.xml', - $remoteUrlAbsolute, - '%s/wsdl_[a-f0-9]{32}\.cache', - 2, - ), - 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(array( - 'proxy_host' => false, - ))); - $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 provideResolveXsdIncludes() - { - $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/build_include/xsdinctest_absolute.xml', - '%s/cache_local_absolute.xml', - null, - '%s/wsdl_[a-f0-9]{32}\.cache', - 2, - ), - array( - __DIR__.DIRECTORY_SEPARATOR.'Fixtures/xsdinclude/xsdinctest_relative.xml', - '%s/cache_local_relative.xml', - null, - '\.\./type_include\.xsd', - 1, - ), - array( - $remoteUrlAbsolute, - '%s/cache_remote_absolute.xml', - $remoteUrlAbsolute, - '%s/wsdl_[a-f0-9]{32}\.cache', - 2, - ), - array( - $remoteUrlRelative, - '%s/cache_remote_relative.xml', - $remoteUrlRelative, - '%s/wsdl_[a-f0-9]{32}\.cache', - 2, - ), - ); - } - - public function testResolveRelativePathInUrl() - { - $wsdlDownloader = new WsdlDownloader(new Curl()); - - $r = new \ReflectionClass($wsdlDownloader); - $m = $r->getMethod('resolveRelativePathInUrl'); - $m->setAccessible(true); - - $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', $m->invoke($wsdlDownloader, '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', './test')); - $this->assertEquals('http://localhost/test', $m->invoke($wsdlDownloader, 'http://localhost/', './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', $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', $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', $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', $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/src/BeSimple/SoapClient/Tests/bin/axis.sh b/src/BeSimple/SoapClient/Tests/bin/axis.sh deleted file mode 100755 index 7c9c59d..0000000 --- a/src/BeSimple/SoapClient/Tests/bin/axis.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $DIR - -VERSION_AXIS=1.5.1 -ZIP_AXIS=axis2-$VERSION_AXIS-bin.zip -if [[ "$VERSION_AXIS" > "1.5.1" ]]; then - PATH_AXIS=http://archive.apache.org/dist/axis/axis2/java/core/$VERSION_AXIS/$ZIP_AXIS -else - PATH_AXIS=http://archive.apache.org/dist/ws/axis2/${VERSION_AXIS//./_}/$ZIP_AXIS -fi - -if [ ! -f "$DIR/$ZIP_AXIS" ]; then - curl -O -s $PATH_AXIS -fi - -VERSION_RAMPART=1.5 -ZIP_RAMPART=rampart-dist-$VERSION_RAMPART-bin.zip -PATH_RAMPART=http://archive.apache.org/dist/axis/axis2/java/rampart/$VERSION_RAMPART/$ZIP_RAMPART - -if [ ! -f "$DIR/$ZIP_RAMPART" ]; then - curl -O -s $PATH_RAMPART -fi - -unzip -o -qq "$DIR/$ZIP_AXIS" - -AXIS_DIR=$DIR/axis2-$VERSION_AXIS - -unzip -o -qq -j "$DIR/$ZIP_RAMPART" '*/lib/*.jar' -d $AXIS_DIR/lib -unzip -o -qq -j "$DIR/$ZIP_RAMPART" '*/modules/*.mar' -d $AXIS_DIR/repository/modules - -cp -r $DIR/../AxisInterop/axis_services/* $AXIS_DIR/repository/services - -$AXIS_DIR/bin/axis2server.sh& - -echo "Waiting until Axis is ready on port 8080" -while [[ -z `curl -s 'http://localhost:8080/axis2/services/' ` ]] -do - echo -n "." - sleep 2s -done - -echo "Axis is up" \ No newline at end of file diff --git a/src/BeSimple/SoapClient/Tests/bin/phpwebserver.sh b/src/BeSimple/SoapClient/Tests/bin/phpwebserver.sh deleted file mode 100755 index 0d07b8e..0000000 --- a/src/BeSimple/SoapClient/Tests/bin/phpwebserver.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -PHPWEBSERVEROK="$( php -r "if (version_compare(phpversion(), '5.4', '<')) { echo 'nok'; } else { echo 'ok'; }" )" - -if [ "$PHPWEBSERVEROK" != "ok" ]; then - echo "No PHP webserver available before version 5.4..." - exit -fi - -DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $DIR - -php -S localhost:8081 -t "$DIR/.."& - -echo "Waiting until PHP webserver is ready on port 8081" -while [[ -z `curl -s 'http://localhost:8081' ` ]] -do - echo -n "." - sleep 2s -done - -echo "PHP webserver is up" \ No newline at end of file diff --git a/src/BeSimple/SoapServer/Tests/SoapServerHandler.php b/src/BeSimple/SoapServer/Tests/SoapServerHandler.php deleted file mode 100644 index 6758491..0000000 --- a/src/BeSimple/SoapServer/Tests/SoapServerHandler.php +++ /dev/null @@ -1,7 +0,0 @@ -getWsdlFile()); + } + + public function testSoapClientOptionsCreateWithDefaults() + { + $defaultOptions = SoapClientOptionsBuilder::createWithDefaults(); + + self::assertInstanceOf(SoapClientOptions::class, $defaultOptions); + self::assertEquals(CurlOptions::DEFAULT_USER_AGENT, $defaultOptions->getUserAgent()); + } + + public function testConstructSoapClientWithDefaults() + { + $soapClient = $this->getSoapBuilder()->build( + SoapClientOptionsBuilder::createWithDefaults(), + SoapOptionsBuilder::createWithDefaults(self::TEST_REMOTE_WSDL_UK) + ); + + self::assertInstanceOf(SoapClient::class, $soapClient); + } + + public function testConstructSoapClientWithSwaAndClassMapAndCacheDisk() + { + $soapOptions = SoapOptionsBuilder::createSwaWithClassMap( + self::TEST_REMOTE_WSDL_UK, + new ClassMap(), + SoapOptions::SOAP_CACHE_TYPE_DISK, + self::CACHE_DIR + ); + + $soapClient = $this->getSoapBuilder()->build( + SoapClientOptionsBuilder::createWithDefaults(), + $soapOptions + ); + + self::assertInstanceOf(SoapClient::class, $soapClient); + } + + public function testConstructSoapClientWithDefaultsAndLocalWsdlFile() + { + $soapClient = $this->getSoapBuilder()->build( + SoapClientOptionsBuilder::createWithDefaults(), + SoapOptionsBuilder::createWithDefaults(self::TEST_LOCAL_WSDL_UK) + ); + + self::assertInstanceOf(SoapClient::class, $soapClient); + } + + public function testConstructSoapClientWithSwaAndClassMapAndCacheDiskAndLocalWsdlFile() + { + $soapOptions = SoapOptionsBuilder::createSwaWithClassMap( + self::TEST_LOCAL_WSDL_UK, + new ClassMap(), + SoapOptions::SOAP_CACHE_TYPE_DISK, + self::CACHE_DIR + ); + + $soapClient = $this->getSoapBuilder()->build( + SoapClientOptionsBuilder::createWithDefaults(), + $soapOptions + ); + + self::assertInstanceOf(SoapClient::class, $soapClient); + } + + private function getSoapBuilder() + { + return new SoapClientBuilder(); + } +} diff --git a/src/BeSimple/SoapClient/Tests/SoapClientBuilderTest.php b/tests/BeSimple/SoapClient/SoapClientTest.php similarity index 77% rename from src/BeSimple/SoapClient/Tests/SoapClientBuilderTest.php rename to tests/BeSimple/SoapClient/SoapClientTest.php index 344588c..1542814 100644 --- a/src/BeSimple/SoapClient/Tests/SoapClientBuilderTest.php +++ b/tests/BeSimple/SoapClient/SoapClientTest.php @@ -1,111 +1,27 @@ - * (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; +namespace BeSimple\SoapClient; use BeSimple\SoapBundle\Soap\SoapAttachment; -use BeSimple\SoapClient\Curl\CurlOptions; -use BeSimple\SoapClient\SoapClientBuilder; -use BeSimple\SoapClient\SoapClientOptionsBuilder; -use BeSimple\SoapClient\SoapFaultWithTracingData; -use BeSimple\SoapClient\SoapOptions\SoapClientOptions; use BeSimple\SoapCommon\ClassMap; use BeSimple\SoapCommon\SoapOptions\SoapOptions; use BeSimple\SoapCommon\SoapOptionsBuilder; use Exception; -use SoapClient; +use Fixtures\GenerateTestRequest; +use Fixtures\GetUKLocationByCounty; +use PHPUnit_Framework_TestCase; use SoapHeader; -class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase +class SoapClientTest extends PHPUnit_Framework_TestCase { - const CACHE_DIR = __DIR__ . '/../../../../cache'; + const CACHE_DIR = __DIR__ . '/../../../cache'; + const FIXTURES_DIR = __DIR__ . '/../../Fixtures'; const TEST_ENDPOINT_UK = 'http://www.webservicex.net/uklocation.asmx'; const TEST_REMOTE_WSDL_UK = 'http://www.webservicex.net/uklocation.asmx?WSDL'; - const TEST_LOCAL_WSDL_UK = __DIR__.'/localWsdl.wsdl'; const TEST_REMOTE_ENDPOINT_NOT_WORKING = 'http://www.nosuchserverexist.tld/doesnotexist.endpoint'; const TEST_REMOTE_WSDL_NOT_WORKING = 'http://www.nosuchserverexist.tld/doesnotexist.endpoint?wsdl'; - const TEST_ENDPOINT_SWA = 'https://demo2815480.mockable.io/soap/testGenerator'; const TEST_REMOTE_WSDL_SWA = 'https://demo2815480.mockable.io/soap/testGenerator?WSDL'; - public function testSoapOptionsCreateWithDefaults() - { - $defaultOptions = SoapOptionsBuilder::createWithDefaults(self::TEST_LOCAL_WSDL_UK); - - self::assertInstanceOf(SoapOptions::class, $defaultOptions); - self::assertEquals(self::TEST_LOCAL_WSDL_UK, $defaultOptions->getWsdlFile()); - } - - public function testSoapClientOptionsCreateWithDefaults() - { - $defaultOptions = SoapClientOptionsBuilder::createWithDefaults(); - - self::assertInstanceOf(SoapClientOptions::class, $defaultOptions); - self::assertEquals(CurlOptions::DEFAULT_USER_AGENT, $defaultOptions->getUserAgent()); - } - - public function testConstructSoapClientWithDefaults() - { - $soapClient = $this->getSoapBuilder()->build( - SoapClientOptionsBuilder::createWithDefaults(), - SoapOptionsBuilder::createWithDefaults(self::TEST_REMOTE_WSDL_UK) - ); - - self::assertInstanceOf(\SoapClient::class, $soapClient); - } - - public function testConstructSoapClientWithSwaAndClassMapAndCacheDisk() - { - $soapOptions = SoapOptionsBuilder::createSwaWithClassMap( - self::TEST_REMOTE_WSDL_UK, - new ClassMap(), - SoapOptions::SOAP_CACHE_TYPE_DISK, - __DIR__.'/../../../../cache' - ); - - $soapClient = $this->getSoapBuilder()->build( - SoapClientOptionsBuilder::createWithDefaults(), - $soapOptions - ); - - self::assertInstanceOf(\SoapClient::class, $soapClient); - } - - public function testConstructSoapClientWithDefaultsAndLocalWsdlFile() - { - $soapClient = $this->getSoapBuilder()->build( - SoapClientOptionsBuilder::createWithDefaults(), - SoapOptionsBuilder::createWithDefaults(self::TEST_LOCAL_WSDL_UK) - ); - - self::assertInstanceOf(\SoapClient::class, $soapClient); - } - - public function testConstructSoapClientWithSwaAndClassMapAndCacheDiskAndLocalWsdlFile() - { - $soapOptions = SoapOptionsBuilder::createSwaWithClassMap( - self::TEST_LOCAL_WSDL_UK, - new ClassMap(), - SoapOptions::SOAP_CACHE_TYPE_DISK, - __DIR__ .'/../../../../cache' - ); - - $soapClient = $this->getSoapBuilder()->build( - SoapClientOptionsBuilder::createWithDefaults(), - $soapOptions - ); - - self::assertInstanceOf(SoapClient::class, $soapClient); - } - public function testSoapCall() { $soapClient = $this->getSoapBuilder()->build( @@ -177,7 +93,7 @@ class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase SoapOptionsBuilder::createWithDefaults( self::TEST_REMOTE_WSDL_NOT_WORKING, SoapOptions::SOAP_CACHE_TYPE_DISK, - __DIR__ .'/../../../../cache' + self::CACHE_DIR ) ); } @@ -224,7 +140,7 @@ class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase self::TEST_REMOTE_WSDL_UK, new ClassMap(), SoapOptions::SOAP_CACHE_TYPE_DISK, - __DIR__ .'/../../../../cache' + self::CACHE_DIR ) ); $getUKLocationByCountyRequest = new GetUKLocationByCounty(); @@ -266,7 +182,7 @@ class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase self::assertContains('start="getLastRequestHeaders(), 'Headers should link to first MultiPart'); self::assertContains('action="', $tracingData->getLastRequestHeaders(), 'Headers should contain SOAP action'); self::assertEquals( - $this->removeOneTimeData(file_get_contents(__DIR__.'/soapRequestWithTwoAttachments.request')), + $this->removeOneTimeData(file_get_contents(self::FIXTURES_DIR.'/soapRequestWithTwoAttachments.request')), $this->removeOneTimeData($tracingData->getLastRequest()), 'Requests must match after onetime data were removed' ); @@ -280,7 +196,7 @@ class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase self::TEST_REMOTE_WSDL_UK, new ClassMap(), SoapOptions::SOAP_CACHE_TYPE_DISK, - __DIR__ .'/../../../../cache' + self::CACHE_DIR ) ); $getUKLocationByCountyRequest = new GetUKLocationByCounty(); @@ -299,8 +215,8 @@ class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase self::assertNotContains('boundary=Part_', $tracingData->getLastRequestHeaders(), 'Headers should link to boundary'); self::assertNotContains('start="getLastRequestHeaders(), 'Headers should link to first MultiPart'); self::assertContains('action="', $tracingData->getLastRequestHeaders(), 'Headers should contain SOAP action'); - self::assertEquals( - file_get_contents(__DIR__.'/soapRequestWithNoAttachments.request'), + self::assertStringEqualsFile( + self::FIXTURES_DIR.'/soapRequestWithNoAttachments.request', $tracingData->getLastRequest(), 'Requests must match' ); @@ -319,7 +235,7 @@ class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase 'GenerateTestRequest' => GenerateTestRequest::class, ]), SoapOptions::SOAP_CACHE_TYPE_DISK, - __DIR__ . '/../../../../cache' + self::CACHE_DIR ), new SoapHeader('http://schema.testcase', 'SoapHeader', [ 'user' => 'admin', @@ -343,11 +259,6 @@ class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase file_put_contents(self::CACHE_DIR . '/testSoapCallSwaWithAttachmentsOnResponse.txt', $firstAttachment->getContent()); } - private function getSoapBuilder() - { - return new SoapClientBuilder(); - } - public function removeOneTimeData($string) { $contentId = $this->getContentId($string); @@ -385,4 +296,9 @@ class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase throw new Exception('Could not find real contentId'); } + + private function getSoapBuilder() + { + return new SoapClientBuilder(); + } } diff --git a/tests/BeSimple/SoapServer/SoapServerBuilderTest.php b/tests/BeSimple/SoapServer/SoapServerBuilderTest.php new file mode 100644 index 0000000..50654bb --- /dev/null +++ b/tests/BeSimple/SoapServer/SoapServerBuilderTest.php @@ -0,0 +1,48 @@ +getWsdlFile()); + } + + public function testSoapServerOptionsCreateWithDefaults() + { + $defaultOptions = SoapServerOptionsBuilder::createWithDefaults(new SoapServerHandler()); + + self::assertInstanceOf(SoapServerOptions::class, $defaultOptions); + self::assertInstanceOf(SoapServerHandler::class, $defaultOptions->getHandlerInstance()); + } + + public function testSoapServerBuilderBuild() + { + $soapServer = $this->getSoapServerBuilder()->build( + SoapServerOptionsBuilder::createWithDefaults(new SoapServerHandler()), + SoapOptionsBuilder::createWithDefaults(self::TEST_LOCAL_WSDL_UK) + ); + + self::assertInstanceOf(SoapServer::class, $soapServer); + } + + public function getSoapServerBuilder() + { + return new SoapServerBuilder(); + } +} diff --git a/src/BeSimple/SoapServer/Tests/SoapServerBuilderTest.php b/tests/BeSimple/SoapServer/SoapServerTest.php similarity index 73% rename from src/BeSimple/SoapServer/Tests/SoapServerBuilderTest.php rename to tests/BeSimple/SoapServer/SoapServerTest.php index 797af77..abb05bc 100644 --- a/src/BeSimple/SoapServer/Tests/SoapServerBuilderTest.php +++ b/tests/BeSimple/SoapServer/SoapServerTest.php @@ -1,56 +1,24 @@ - * (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\SoapServer; -namespace BeSimple\SoapServer\Tests; - -use BeSimple\SoapClient\Tests\SoapClientBuilderTest; +use BeSimple\SoapClient\SoapClientBuilderTest; use BeSimple\SoapCommon\ClassMap; -use BeSimple\SoapCommon\SoapOptions\SoapOptions; use BeSimple\SoapCommon\SoapOptionsBuilder; -use BeSimple\SoapServer\SoapOptions\SoapServerOptions; -use BeSimple\SoapServer\SoapServerBuilder; -use BeSimple\SoapServer\SoapServerOptionsBuilder; +use Fixtures\DummyService; +use Fixtures\SoapServerHandler; +use PHPUnit_Framework_TestCase; -/** - * UnitTest for \BeSimple\SoapServer\SoapServerBuilder - * - * @author Christian Kerl - * @author Petr Bechyne - */ -class SoapServerBuilderTest extends \PHPUnit_Framework_TestCase +class SoapServerTest extends PHPUnit_Framework_TestCase { + const CACHE_DIR = __DIR__ . '/../../../cache'; + const FIXTURES_DIR = __DIR__ . '/../../Fixtures'; const TEST_LOCAL_WSDL_UK = SoapClientBuilderTest::TEST_LOCAL_WSDL_UK; - const CACHE_DIR = __DIR__ . '/../../../../cache'; - public function testSoapOptionsCreateWithDefaults() - { - $defaultOptions = SoapOptionsBuilder::createWithDefaults(self::TEST_LOCAL_WSDL_UK); - - self::assertInstanceOf(SoapOptions::class, $defaultOptions); - self::assertEquals(self::TEST_LOCAL_WSDL_UK, $defaultOptions->getWsdlFile()); - } - - public function testSoapClientOptionsCreateWithDefaults() - { - $defaultOptions = SoapServerOptionsBuilder::createWithDefaults(new SoapServerHandler); - - self::assertInstanceOf(SoapServerOptions::class, $defaultOptions); - self::assertInstanceOf(SoapServerHandler::class, $defaultOptions->getHandlerInstance()); - } - - public function testSoapServerBuilderBuild() + public function testCreateRequest() { $soapServer = $this->getSoapServerBuilder()->build( - SoapServerOptionsBuilder::createWithDefaults(new SoapServerHandler), + SoapServerOptionsBuilder::createWithDefaults(new SoapServerHandler()), SoapOptionsBuilder::createWithDefaults(self::TEST_LOCAL_WSDL_UK) ); $soapRequest = $soapServer->createRequest('request-url', 'soap-action', 'content/type', 'request-content'); @@ -78,7 +46,7 @@ class SoapServerBuilderTest extends \PHPUnit_Framework_TestCase $dummyService->getEndpoint(), 'DummyService.dummyServiceMethod', 'text/xml;charset=UTF-8', - file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'testHandleRequest.message') + file_get_contents(self::FIXTURES_DIR.DIRECTORY_SEPARATOR.'testHandleRequest.message') ); $response = $soapServer->handleRequest($request); @@ -106,7 +74,7 @@ class SoapServerBuilderTest extends \PHPUnit_Framework_TestCase $dummyService->getEndpoint(), 'DummyService.dummyServiceMethodWithAttachments', 'text/xml;charset=UTF-8', - file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'testHandleRequestWithSwa.message') + file_get_contents(self::FIXTURES_DIR.DIRECTORY_SEPARATOR.'testHandleRequestWithSwa.message') ); $response = $soapServer->handleRequest($request); @@ -134,7 +102,7 @@ class SoapServerBuilderTest extends \PHPUnit_Framework_TestCase $dummyService->getEndpoint(), 'DummyService.dummyServiceMethodWithAttachments', 'multipart/related; type="text/xml"; start=""; boundary="----=_Part_6_2094841787.1482231370463"', - file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'testHandleRequestWithSwa.mimepart.message') + file_get_contents(self::FIXTURES_DIR.DIRECTORY_SEPARATOR.'testHandleRequestWithSwa.mimepart.message') ); $response = $soapServer->handleRequest($request); diff --git a/src/BeSimple/SoapServer/Tests/Attachment/Attachment.php b/tests/Fixtures/Attachment/Attachment.php similarity index 92% rename from src/BeSimple/SoapServer/Tests/Attachment/Attachment.php rename to tests/Fixtures/Attachment/Attachment.php index 77046b1..e722951 100644 --- a/src/BeSimple/SoapServer/Tests/Attachment/Attachment.php +++ b/tests/Fixtures/Attachment/Attachment.php @@ -1,6 +1,6 @@