Skip to content

Commit

Permalink
Merge pull request #10 from David-Hoagland/PHP8
Browse files Browse the repository at this point in the history
Updated for PHP 8 compatibility
  • Loading branch information
dcarbone authored Aug 17, 2022
2 parents 6d62a3e + 56c5426 commit 5b88589
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
],

"require" : {
"php" : ">=5.4.0",
"php" : "^8.0",
"lib-curl" : "*",
"lib-libxml" : "*",
"ext-soap" : "*",
"dcarbone/curl-plus": "3.0.*"
},

"require-dev" : {
"phpunit/phpunit": "~4.1"
"phpunit/phpunit": "^8.0 || ^9.0"
},

"autoload" : {
Expand Down
6 changes: 3 additions & 3 deletions src/SoapClientPlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function __construct($wsdl, array $options = array())
else
$this->_sxeArgs = LIBXML_COMPACT | LIBXML_NOBLANKS;

parent::SoapClient($wsdl, $this->_soapOptions);
parent::__construct($wsdl, $this->_soapOptions);
}

/**
Expand Down Expand Up @@ -371,7 +371,7 @@ public function createArgumentArrayFromXML($arguments, $function_name)
{
try {
libxml_use_internal_errors(true);
$sxe = new \SimpleXMLElement(trim($arguments), $this->_sxeArgs);
$sxe = new \SimpleXMLElement(trim($arguments), $this->_sxeArgs, str_contains($arguments, 'http'));
}
catch (\Exception $e)
{
Expand Down Expand Up @@ -498,7 +498,7 @@ public function __doRequest($request, $location, $action, $version, $one_way = 0
$this->getCurlClient()->setRequestHeader($k, $v);
}
$this->curlPlusClient->setRequestHeader('SOAPAction', $action);

$ret = $this->curlPlusClient->execute();

if ($this->debugEnabled())
Expand Down
49 changes: 28 additions & 21 deletions tests/SoapPlus/SoapClientPlusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
/**
* Class SoapClientTest
*/
class SoapClientPlusTest extends \PHPUnit_Framework_TestCase
class SoapClientPlusTest extends \PHPUnit\Framework\TestCase
{
/** @var string */
public static $weatherWSDL = 'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL';
public static $weatherWSDL = "http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?WSDL";

/**
* @covers \DCarbone\SoapPlus\SoapClientPlus::__construct
Expand All @@ -24,6 +24,7 @@ class SoapClientPlusTest extends \PHPUnit_Framework_TestCase
*/
public function testCanConstructSoapClientPlusWithNoOptions()
{
echo self::$weatherWSDL;
$soapClient = new \DCarbone\SoapPlus\SoapClientPlus(self::$weatherWSDL);

$this->assertInstanceOf('\\DCarbone\\SoapPlus\\SoapClientPlus', $soapClient);
Expand Down Expand Up @@ -96,12 +97,12 @@ public function testCanGetReadOnlyParameters(\DCarbone\SoapPlus\SoapClientPlus $
$wsdlCachePath = $soapClient->wsdlCachePath;
$wsdlTmpName = $soapClient->wsdlTmpFileName;

$this->assertInternalType('array', $options);
$this->assertInternalType('array', $soapOptions);
$this->assertInternalType('array', $debugQueries);
$this->assertInternalType('array', $debugResults);
$this->assertInternalType('string', $wsdlCachePath);
$this->assertInternalType('string', $wsdlTmpName);
$this->assertIsArray($options);
$this->assertIsArray($soapOptions);
$this->assertIsArray($debugQueries);
$this->assertIsArray($debugResults);
$this->assertIsString($wsdlCachePath);
$this->assertIsString($wsdlTmpName);
}

/**
Expand All @@ -113,7 +114,8 @@ public function testCanGetReadOnlyParameters(\DCarbone\SoapPlus\SoapClientPlus $
*/
public function testExceptionThrownWhenTryingToGetInvalidProperty(\DCarbone\SoapPlus\SoapClientPlus $soapClient)
{
$nope = $soapClient->nope;
$this->expectException(OutOfBoundsException::class);
$nope = $soapClient->nope;
}

/**
Expand All @@ -128,14 +130,15 @@ public function testExceptionThrownWhenTryingToGetInvalidProperty(\DCarbone\Soap
public function testCanGetWeatherForecastWithArrayRequest(\DCarbone\SoapPlus\SoapClientPlus $soapClient)
{
$array = array(
'GetCityForecastByZIP' => array(
'ZIP' => '37209',
'VerifyEmail' => array(
'email' => '[email protected]',
'LicenseKey' => ''
),
);

$response = $soapClient->GetCityForecastByZIP($array);
$this->assertInternalType('object', $response);
$this->assertObjectHasAttribute('GetCityForecastByZIPResult', $response);
$response = $soapClient->VerifyEmail($array);
$this->assertIsObject($response);
$this->assertObjectHasAttribute('VerifyEmailResult', $response);
}

/**
Expand All @@ -152,14 +155,15 @@ public function testCanGetWeatherForecastWithArrayRequest(\DCarbone\SoapPlus\Soa
public function testCanGetWeatherForecastWithXMLRequest(\DCarbone\SoapPlus\SoapClientPlus $soapClient)
{
$xml = <<<XML
<GetCityForecastByZIP>
<ZIP>37209</ZIP>
</GetCityForecastByZIP>
<VerifyEmail>
<email>[email protected]</email>
<LicenseKey></LicenseKey>
</VerifyEmail>
XML;

$response = $soapClient->GetCityForecastByZIP($xml);
$this->assertInternalType('object', $response);
$this->assertObjectHasAttribute('GetCityForecastByZIPResult', $response);
$response = $soapClient->VerifyEmail($xml);
$this->assertIsObject($response);
$this->assertObjectHasAttribute('VerifyEmailResult', $response);
}

/**
Expand Down Expand Up @@ -192,6 +196,7 @@ public function testCanConstructSoapClientPlusWithValidAuthCredentials()
*/
public function testExceptionThrownWhenInvalidAuthTypeSpecified()
{
$this->expectException(InvalidArgumentException::class);
$soapClient = new \DCarbone\SoapPlus\SoapClientPlus(self::$weatherWSDL, array(
'wsdl_cache_path' => __DIR__.'/../misc/wsdl-cache',
'login' => 'my_login',
Expand Down Expand Up @@ -231,6 +236,7 @@ public function testNonSoapOptionsProperlyRemoved(\DCarbone\SoapPlus\SoapClientP
*/
public function testExceptionThrownWhenAttemptingToSetWSDLCacheMemory()
{
$this->expectException(RuntimeException::class);
$soapClient = new \DCarbone\SoapPlus\SoapClientPlus(self::$weatherWSDL, array(
'cache_wsdl' => WSDL_CACHE_MEMORY,
));
Expand All @@ -242,6 +248,7 @@ public function testExceptionThrownWhenAttemptingToSetWSDLCacheMemory()
*/
public function testExceptionThrownWhenAttemptingToSetWSDLCacheBoth()
{
$this->expectException(RuntimeException::class);
$soapClient = new \DCarbone\SoapPlus\SoapClientPlus(self::$weatherWSDL, array(
'cache_wsdl' => WSDL_CACHE_BOTH,
));
Expand Down Expand Up @@ -321,6 +328,6 @@ public function testCanGetDefaultRequestHeaders(\DCarbone\SoapPlus\SoapClientPlu
{
$defaultHeaders = $soapClient->getRequestHeaders();

$this->assertInternalType('array', $defaultHeaders);
$this->assertIsArray($defaultHeaders);
}
}

0 comments on commit 5b88589

Please sign in to comment.