Skip to content

Commit

Permalink
Update loader in CodeGeneratorEngineFactory
Browse files Browse the repository at this point in the history
The code update removes the dependency on Psr18ClientDiscovery and Psr18Loader and replaces it with StreamWrapperLoader in the CodeGeneratorEngineFactory. Additionally, a corresponding test for this change has been created in CodeGeneratorEngineFactoryTest to verify that the engine can be correctly loaded from the filesystem.

Fixes #510
  • Loading branch information
janvernieuwe committed Apr 26, 2024
1 parent 7b7cd0e commit 29be0c6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Phpro/SoapClient/Soap/CodeGeneratorEngineFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace Phpro\SoapClient\Soap;

use Http\Discovery\Psr18ClientDiscovery;
use Phpro\SoapClient\Soap\ExtSoap\Metadata\Manipulators\DuplicateTypes\IntersectDuplicateTypesStrategy;
use Phpro\SoapClient\Soap\Metadata\MetadataFactory;
use Phpro\SoapClient\Soap\Metadata\MetadataOptions;
Expand All @@ -12,8 +11,8 @@
use Soap\Engine\NoopTransport;
use Soap\Engine\PartialDriver;
use Soap\Engine\SimpleEngine;
use Soap\Psr18Transport\Wsdl\Psr18Loader;
use Soap\Wsdl\Loader\FlatteningLoader;
use Soap\Wsdl\Loader\StreamWrapperLoader;
use Soap\Wsdl\Loader\WsdlLoader;
use Soap\WsdlReader\Locator\ServiceSelectionCriteria;
use Soap\WsdlReader\Metadata\Wsdl1MetadataProvider;
Expand All @@ -33,7 +32,7 @@ public static function create(
?SoapVersion $preferredSoapVersion = null,
?ParserContext $parserContext = null,
): Engine {
$loader ??= new FlatteningLoader(Psr18Loader::createForClient(Psr18ClientDiscovery::find()));
$loader ??= new FlatteningLoader(new StreamWrapperLoader());
$metadataOptions ??= MetadataOptions::empty()->withTypesManipulator(
// Ext-soap is not able to work with duplicate types (see FAQ)
// Therefore, we decided to combine all duplicate types into 1 big intersected type by default instead.
Expand Down
17 changes: 17 additions & 0 deletions test/Phpro/SoapClient/Soap/CodeGeneratorEngineFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Phpro\SoapClient\Soap;

use PHPUnit\Framework\TestCase;
use Soap\Engine\Engine;
use Soap\Engine\Metadata\Metadata;

class CodeGeneratorEngineFactoryTest extends TestCase
{
public function test_it_loads_from_filesystem(): void
{
$engine = CodeGeneratorEngineFactory::create(__DIR__ . '/../../../fixtures/wsdl/functional/calculator.wsdl');
$this->assertInstanceOf(Engine::class, $engine);
self::assertInstanceOf(Metadata::class, $engine->getMetadata());
}
}

0 comments on commit 29be0c6

Please sign in to comment.