Skip to content

Commit

Permalink
Merge branch 'release/5.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelcom committed Feb 5, 2024
2 parents f59c085 + 3816218 commit d2ac19e
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/sonars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Monitor coverage
uses: slavcodev/coverage-monitor-action@v1
with:
github_token: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
coverage_path: coverage.xml
threshold_alert: 95
threshold_warning: 90
Expand All @@ -44,5 +44,5 @@ jobs:
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## 5.0.4 - 2024/02/05
- PR #51 - Fix overriding the custom SoapClient class

## 5.0.3 - 2023/02/09
- PR #38 - type checking exception raised in php8

Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
{
"name": "maurobn",
"role": "Contributor"
},
{
"name": "Christo Yovev",
"role": "Contributor"
}
],
"support" : {
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractSoapClientBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected static function canInstantiateSoapClientWithOptions(array $wsdlOptions
*/
public function getSoapClientClassName(?string $soapClientClassName = null): string
{
$className = self::DEFAULT_SOAP_CLIENT_CLASS;
$className = static::DEFAULT_SOAP_CLIENT_CLASS;
if (!empty($soapClientClassName) && is_subclass_of($soapClientClassName, SoapClient::class)) {
$className = $soapClientClassName;
}
Expand Down
26 changes: 26 additions & 0 deletions tests/CustomSoapClientService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace WsdlToPhp\PackageBase\Tests;

use WsdlToPhp\PackageBase\AbstractSoapClientBase;

/**
* Services can specify a custom SoapClient class
* to be used instead of PHP default by overriding
* the constant below.
*
* @see \WsdlToPhp\PackageBase\SoapClientInterface
* @see \WsdlToPhp\PackageBase\AbstractSoapClientBase :: getSoapClientClassName()
*/

class CustomSoapClientService extends AbstractSoapClientBase
{

/**
* Custom SoapClient class used for current service.
*/
const DEFAULT_SOAP_CLIENT_CLASS = Client::class;

}
17 changes: 17 additions & 0 deletions tests/DefaultSoapClientService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace WsdlToPhp\PackageBase\Tests;

use WsdlToPhp\PackageBase\AbstractSoapClientBase;

/**
* By default all services extending the packagebase's
* abstract class rely on PHP's default SoapClient.
*/

class DefaultSoapClientService extends AbstractSoapClientBase
{

}
10 changes: 10 additions & 0 deletions tests/SoapClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ public function testSoapClientNameDefault(): void
$this->assertSame(Client::class, $soapClient->getSoapClientClassName(Client::class));
}

public function testCustomSoapClientNameReadFromConstant()
{
$defaultService = new DefaultSoapClientService();
$customService = new CustomSoapClientService();

$this->assertSame(SoapClientBase::class, $defaultService->getSoapClientClassName());
$this->assertSame(Client::class, $customService->getSoapClientClassName());
}

public function testSoapClient(): void
{
$soapClient = new SoapClient([
Expand Down Expand Up @@ -489,4 +498,5 @@ public function testGetOutputHeadersWithoutRequestMustReturnAnEmptyArray(): void
$this->assertTrue(is_array($soapClient->getOutputHeaders()));
$this->assertEmpty($soapClient->getOutputHeaders());
}

}

0 comments on commit d2ac19e

Please sign in to comment.