|
3 | 3 | namespace WsdlToPhp\PackageBase\Tests; |
4 | 4 |
|
5 | 5 |
|
| 6 | +use WsdlToPhp\PackageBase\Utils; |
| 7 | + |
6 | 8 | use WsdlToPhp\PackageBase\Tests\SoapClient; |
7 | 9 |
|
8 | 10 | class SoapClientTest extends TestCase |
@@ -37,6 +39,161 @@ public function testSoapClient() |
37 | 39 |
|
38 | 40 | $this->assertInstanceOf('\\WsdlToPhp\\PackageBase\\Tests\\Client', $soapClient->getSoapClient()); |
39 | 41 | } |
| 42 | + /** |
| 43 | + * |
| 44 | + */ |
| 45 | + public function testSetLocation() |
| 46 | + { |
| 47 | + $soapClient = new SoapClient(array( |
| 48 | + SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl', |
| 49 | + SoapClient::WSDL_CLASSMAP => self::classMap(), |
| 50 | + )); |
| 51 | + |
| 52 | + $soapClient->setLocation('http://api.bing.net:80/soap.asm'); |
| 53 | + |
| 54 | + $this->assertSAme('http://api.bing.net:80/soap.asm', $soapClient->getSoapClient()->location); |
| 55 | + } |
| 56 | + /** |
| 57 | + * |
| 58 | + */ |
| 59 | + public function testGetLastRequestAsString() |
| 60 | + { |
| 61 | + $soapClient = new SoapClient(array( |
| 62 | + SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl', |
| 63 | + SoapClient::WSDL_CLASSMAP => self::classMap(), |
| 64 | + )); |
| 65 | + |
| 66 | + $this->assertSame(Utils::getFormatedXml(file_get_contents(__DIR__ . '/resources/oneline.xml')), $soapClient->getLastRequest(false)); |
| 67 | + } |
| 68 | + /** |
| 69 | + * |
| 70 | + */ |
| 71 | + public function testGetLastRequestAsDomDocument() |
| 72 | + { |
| 73 | + $soapClient = new SoapClient(array( |
| 74 | + SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl', |
| 75 | + SoapClient::WSDL_CLASSMAP => self::classMap(), |
| 76 | + )); |
| 77 | + |
| 78 | + $this->assertInstanceOf('\\DOMDocument', $soapClient->getLastRequest(true)); |
| 79 | + } |
| 80 | + /** |
| 81 | + * |
| 82 | + */ |
| 83 | + public function testGetLastResponseAsString() |
| 84 | + { |
| 85 | + $soapClient = new SoapClient(array( |
| 86 | + SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl', |
| 87 | + SoapClient::WSDL_CLASSMAP => self::classMap(), |
| 88 | + )); |
| 89 | + |
| 90 | + $this->assertSame(Utils::getFormatedXml(file_get_contents(__DIR__ . '/resources/oneline.xml')), $soapClient->getLastResponse(false)); |
| 91 | + } |
| 92 | + /** |
| 93 | + * |
| 94 | + */ |
| 95 | + public function testGetLastResponseAsDomDocument() |
| 96 | + { |
| 97 | + $soapClient = new SoapClient(array( |
| 98 | + SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl', |
| 99 | + SoapClient::WSDL_CLASSMAP => self::classMap(), |
| 100 | + )); |
| 101 | + |
| 102 | + $this->assertInstanceOf('\\DOMDocument', $soapClient->getLastResponse(true)); |
| 103 | + } |
| 104 | + /** |
| 105 | + * |
| 106 | + */ |
| 107 | + public function testGetLastRequestHeadersAsString() |
| 108 | + { |
| 109 | + $soapClient = new SoapClient(array( |
| 110 | + SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl', |
| 111 | + SoapClient::WSDL_CLASSMAP => self::classMap(), |
| 112 | + )); |
| 113 | + |
| 114 | + $this->assertSame($soapClient->getSoapClient()->__getLastRequestHeaders(), $soapClient->getLastRequestHeaders(false)); |
| 115 | + } |
| 116 | + /** |
| 117 | + * |
| 118 | + */ |
| 119 | + public function testGetLastRequestHeadersAsArray() |
| 120 | + { |
| 121 | + $soapClient = new SoapClient(array( |
| 122 | + SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl', |
| 123 | + SoapClient::WSDL_CLASSMAP => self::classMap(), |
| 124 | + )); |
| 125 | + |
| 126 | + $this->assertSame($soapClient->getSoapClient()->getLastRequestHeadersAsArray(), $soapClient->getLastRequestHeaders(true)); |
| 127 | + } |
| 128 | + /** |
| 129 | + * |
| 130 | + */ |
| 131 | + public function testGetLastResponseHeadersAsString() |
| 132 | + { |
| 133 | + $soapClient = new SoapClient(array( |
| 134 | + SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl', |
| 135 | + SoapClient::WSDL_CLASSMAP => self::classMap(), |
| 136 | + )); |
| 137 | + |
| 138 | + $this->assertSame($soapClient->getSoapClient()->__getLastResponseHeaders(), $soapClient->getLastResponseHeaders(false)); |
| 139 | + } |
| 140 | + /** |
| 141 | + * |
| 142 | + */ |
| 143 | + public function testGetLastResponseHeadersAsArray() |
| 144 | + { |
| 145 | + $soapClient = new SoapClient(array( |
| 146 | + SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl', |
| 147 | + SoapClient::WSDL_CLASSMAP => self::classMap(), |
| 148 | + )); |
| 149 | + |
| 150 | + $this->assertSame($soapClient->getSoapClient()->getLastResponseHeadersAsArray(), $soapClient->getLastResponseHeaders(true)); |
| 151 | + } |
| 152 | + /** |
| 153 | + * |
| 154 | + */ |
| 155 | + public function testSetGetLastErrorForMethod() |
| 156 | + { |
| 157 | + $soapClient = new SoapClient(array( |
| 158 | + SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl', |
| 159 | + SoapClient::WSDL_CLASSMAP => self::classMap(), |
| 160 | + )); |
| 161 | + |
| 162 | + // this call should fail as no parameter is defined in the request |
| 163 | + $soapClient->search(); |
| 164 | + |
| 165 | + $this->assertInstanceOf('\\SoapFault', $soapClient->getLastErrorForMethod('WsdlToPhp\PackageBase\Tests\SoapClient::search')); |
| 166 | + } |
| 167 | + /** |
| 168 | + * |
| 169 | + */ |
| 170 | + public function testSetGetLastError() |
| 171 | + { |
| 172 | + $soapClient = new SoapClient(array( |
| 173 | + SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl', |
| 174 | + SoapClient::WSDL_CLASSMAP => self::classMap(), |
| 175 | + )); |
| 176 | + |
| 177 | + // this call should fail as no parameter is defined in the request |
| 178 | + $soapClient->search(); |
| 179 | + |
| 180 | + $this->assertCount(1, $soapClient->getLastError()); |
| 181 | + } |
| 182 | + /** |
| 183 | + * |
| 184 | + */ |
| 185 | + public function testSetGetResult() |
| 186 | + { |
| 187 | + $soapClient = new SoapClient(array( |
| 188 | + SoapClient::WSDL_URL => __DIR__ . '/resources/bingsearch.wsdl', |
| 189 | + SoapClient::WSDL_CLASSMAP => self::classMap(), |
| 190 | + )); |
| 191 | + |
| 192 | + // this call should fail as no parameter is defined in the request |
| 193 | + $soapClient->search(); |
| 194 | + |
| 195 | + $this->assertNull($soapClient->getResult()); |
| 196 | + } |
40 | 197 | /** |
41 | 198 | * @return string[] |
42 | 199 | */ |
|
0 commit comments