Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Client/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace CodeDredd\Soap\Client;

use CodeDredd\Soap\Xml\SoapXml;
use CodeDredd\Soap\Xml\XMLSerializer;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
Expand Down
1 change: 0 additions & 1 deletion src/Driver/ExtSoap/ExtSoapEngineFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public static function fromOptionsWithHandler(
): EngineFaker|SimpleEngine {
$driver = ExtSoapDriver::createFromOptions($options);
if ($withMocking) {

}

return $withMocking ? new EngineFaker($driver, $transport, $options) : new SimpleEngine($driver, $transport);
Expand Down
1 change: 0 additions & 1 deletion src/Faker/EngineFaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ public function getMetadata(): Metadata
{
return $this->driver->getMetadata();
}

}
6 changes: 3 additions & 3 deletions src/Middleware/CisDhlMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
use Http\Client\Common\Plugin;
use Http\Promise\Promise;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Soap\Psr18Transport\Xml\XmlMessageManipulator;
use Soap\Xml\Builder\SoapHeader;
use Soap\Xml\Builder\SoapHeaders;
use Soap\Xml\Manipulator\PrependSoapHeaders;
use VeeWee\Xml\Dom\Document;
use Psr\Http\Message\ResponseInterface;
use function VeeWee\Xml\Dom\Builder\children;
use function VeeWee\Xml\Dom\Builder\namespaced_element;
use function VeeWee\Xml\Dom\Builder\value;
use VeeWee\Xml\Dom\Document;

class CisDhlMiddleware implements Plugin
{
Expand Down Expand Up @@ -48,7 +48,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
return $next(
(new XmlMessageManipulator)(
$request,
function (Document $document) use ($request) {
function (Document $document) {
$builder = new SoapHeaders(
new SoapHeader(
self::CIS_NS,
Expand Down
10 changes: 4 additions & 6 deletions src/Middleware/WsseMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ function (Document $xml) {
$wsse->attachTokentoSig($token);
}



// Add end-to-end encryption if configured:
if ($this->encrypt) {
$key = new XMLSecurityKey(XMLSecurityKey::AES256_CBC);
Expand All @@ -131,7 +129,7 @@ function (Document $xml) {
$wsse->encryptSoapDoc($siteKey, $key, [
'KeyInfo' => [
'X509SubjectKeyIdentifier' => $this->serverCertificateHasSubjectKeyIdentifier,
]
],
]);
}
}
Expand All @@ -142,7 +140,7 @@ function (Document $xml) {

public function afterResponse(ResponseInterface $response): ResponseInterface
{
if (!$this->encrypt) {
if (! $this->encrypt) {
return $response;
}

Expand All @@ -158,8 +156,8 @@ function (Document $xml) {
'key' => $this->privateKeyFile,
'isFile' => true,
'isCert' => false,
]
]
],
],
]
);
}
Expand Down
18 changes: 7 additions & 11 deletions src/SoapClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@
use CodeDredd\Soap\Driver\ExtSoap\ExtSoapEngineFactory;
use CodeDredd\Soap\Exceptions\NotFoundConfigurationException;
use CodeDredd\Soap\Exceptions\SoapException;
use CodeDredd\Soap\Faker\EngineFaker;
use CodeDredd\Soap\Middleware\CisDhlMiddleware;
use CodeDredd\Soap\Middleware\WsseMiddleware;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use Http\Client\Common\PluginClient;
use Http\Client\Exception\HttpException;
use Http\Client\HttpClient;
use Http\Discovery\Psr17FactoryDiscovery;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\Macroable;
use Phpro\SoapClient\Type\ResultInterface;
Expand All @@ -27,7 +24,6 @@
use Soap\Engine\Transport;
use Soap\ExtSoapEngine\ExtSoapOptions;
use Soap\ExtSoapEngine\Transport\TraceableTransport;
use Soap\ExtSoapEngine\Wsdl\InMemoryWsdlProvider;
use Soap\ExtSoapEngine\Wsdl\PassThroughWsdlProvider;
use Soap\ExtSoapEngine\Wsdl\WsdlProvider;
use Soap\Psr18Transport\Psr18Transport;
Expand Down Expand Up @@ -137,7 +133,8 @@ function (Request $request, array $options) {
]);
}

public function refreshWsdlProvider(){
public function refreshWsdlProvider()
{
$this->wsdlProvider = Psr18Loader::createForClient($this->pluginClient);

return $this;
Expand Down Expand Up @@ -170,7 +167,6 @@ protected function setTransport(Transport $handler = null): static
$transport
);


return $this;
}

Expand Down Expand Up @@ -205,10 +201,10 @@ public function withGuzzleClientOptions($options)
{
$this->guzzleClientOptions = array_merge_recursive($this->guzzleClientOptions, $options);
$this->client = new Client($this->guzzleClientOptions);

return $this;
}


public function getEngine(): Engine
{
return $this->engine;
Expand Down Expand Up @@ -369,7 +365,7 @@ public function __call($method, $parameters)
public function call(string $method, $arguments = []): Response
{
try {
if (!$this->isClientBuilded) {
if (! $this->isClientBuilded) {
$this->buildClient();
}
$this->refreshEngine();
Expand All @@ -384,7 +380,7 @@ public function call(string $method, $arguments = []): Response
if ($result instanceof ResultProviderInterface) {
$result = Response::fromSoapResponse($result->getResult());
}
if (!$result instanceof ResultInterface) {
if (! $result instanceof ResultInterface) {
$result = Response::fromSoapResponse($result);
}
} catch (\Exception $exception) {
Expand Down Expand Up @@ -430,9 +426,9 @@ public function buildClient(string $setup = '')
*/
public function byConfig(string $setup)
{
if (!empty($setup)) {
if (! empty($setup)) {
$setup = config()->get('soap.clients.'.$setup);
if (!$setup) {
if (! $setup) {
throw new NotFoundConfigurationException($setup);
}
foreach ($setup as $setupItem => $setupItemConfig) {
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/Commands/MakeValidationCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class MakeValidationCommandTest extends TestCase
{

public function testConsoleCommand()
{
$this->markTestSkipped('wsdl2Php package has been removed. Needs refactoring');
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Middleware/CisDhlMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CisDhlMiddlewareTest extends TestCase
public function testCisDHLMiddleware()
{
Soap::fake();
$client = Soap::withCisDHLAuth('test', 'dhl')->baseWsdl(dirname(__DIR__, 2) . '/Fixtures/Wsdl/weather.wsdl');
$client = Soap::withCisDHLAuth('test', 'dhl')->baseWsdl(dirname(__DIR__, 2).'/Fixtures/Wsdl/weather.wsdl');
$response = $client->call('GetWeatherInformation');
Soap::assertSent(function (Request $request) {
return Str::contains($request->xmlContent(), '<cis:Authentification');
Expand Down
19 changes: 9 additions & 10 deletions tests/Unit/SoapClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use CodeDredd\Soap\Tests\Fixtures\CustomSoapClient;
use CodeDredd\Soap\Tests\TestCase;
use GuzzleHttp\RedirectMiddleware;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;

class SoapClientTest extends TestCase
Expand All @@ -24,7 +23,7 @@ public function testSimpleCall()
{
Soap::fake();
Soap::assertNothingSent();
$response = Soap::baseWsdl(dirname(__DIR__, 1) . '/Fixtures/Wsdl/weather.wsdl')
$response = Soap::baseWsdl(dirname(__DIR__, 1).'/Fixtures/Wsdl/weather.wsdl')
->call('GetWeatherInformation');
self::assertTrue($response->ok());
Soap::assertSent(function (Request $request) {
Expand All @@ -46,14 +45,14 @@ public function testMagicCallByConfig()
public function testWsseWithWsaCall()
{
Soap::fake();
$client = Soap::baseWsdl(dirname(__DIR__, 1) . '/Fixtures/Wsdl/weather.wsdl')->withWsse([
$client = Soap::baseWsdl(dirname(__DIR__, 1).'/Fixtures/Wsdl/weather.wsdl')->withWsse([
'userTokenName' => 'Test',
'userTokenPassword' => 'passwordTest',
'mustUnderstand' => false,
])->withWsa();
$response = $client->GetWeatherInformation();
Soap::assertSent(function (Request $request) {
return !Str::contains($request->xmlContent(), 'mustUnderstand');
return ! Str::contains($request->xmlContent(), 'mustUnderstand');
});
self::assertTrue($response->ok());
}
Expand Down Expand Up @@ -116,7 +115,7 @@ public function testSoapFake($action, $fake, $exspected)
return Soap::response($item);
})->all();
Soap::fake($fake);
$response = Soap::baseWsdl(dirname(__DIR__, 1) . '/Fixtures/Wsdl/weather.wsdl')
$response = Soap::baseWsdl(dirname(__DIR__, 1).'/Fixtures/Wsdl/weather.wsdl')
->call($action);
self::assertEquals($exspected, $response->json());
}
Expand Down Expand Up @@ -149,10 +148,10 @@ public function testSoapOptions(): void
{
Soap::fake();
$client = Soap::withOptions(['soap_version' => SOAP_1_2])
->baseWsdl(dirname(__DIR__, 1) . '/Fixtures/Wsdl/weather.wsdl');
->baseWsdl(dirname(__DIR__, 1).'/Fixtures/Wsdl/weather.wsdl');
$response = $client->call('GetWeatherInformation');
self::assertTrue($response->ok());
Soap::assertSent(function (Request $request) {
Soap::assertSent(function (Request $request) {
return Str::contains(
$request->getRequest()->getHeaderLine('Content-Type'),
'application/soap+xml; charset="utf-8"'
Expand Down Expand Up @@ -190,9 +189,9 @@ public function testRealSoapCall(): void
public function testSoapWithDifferentHeaders($header, $exspected): void
{
Soap::fake();
$client = Soap::withHeaders($header)->baseWsdl(dirname(__DIR__, 1) . '/Fixtures/Wsdl/weather.wsdl');
$client = Soap::withHeaders($header)->baseWsdl(dirname(__DIR__, 1).'/Fixtures/Wsdl/weather.wsdl');
$response = $client->call('GetWeatherInformation');
Soap::assertSent(function (Request $request) use ($exspected) {
Soap::assertSent(function (Request $request) use ($exspected) {
return $request->getRequest()->getHeaderLine('test') === $exspected;
});
self::assertTrue($response->ok());
Expand Down Expand Up @@ -224,7 +223,7 @@ public function testSoapClientClassMayBeCustomized(): void
public function testHandlerOptions(): void
{
Soap::fake();
$client = Soap::baseWsdl(dirname(__DIR__, 1) . '/Fixtures/Wsdl/weather.wsdl');
$client = Soap::baseWsdl(dirname(__DIR__, 1).'/Fixtures/Wsdl/weather.wsdl');
$response = $client->call('GetWeatherInformation');
self::assertTrue($response->ok());
self::assertEquals(true, $client->getClient()->getConfig()['verify']);
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/Xml/XmlSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace CodeDredd\Soap\Tests\Unit\Xml;

use CodeDredd\Soap\Tests\TestCase;
use CodeDredd\Soap\Xml\SoapXml;
use CodeDredd\Soap\Xml\XMLSerializer;

class XmlSerializerTest extends TestCase
Expand Down