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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ try {
}
```

> Note that if you have `ext-xdebug` loaded, this may halt with a fatal
error instead of throwing a `SoapFault`. It is not recommended to use this
extension in production, so this should only ever affect test environments.
> Note that if you have an old version of `ext-xdebug` < 2.7 loaded, this may
halt with a fatal error instead of throwing a `SoapFault`. It is not
recommended to use this extension in production, so this should only ever
affect test environments.

The `Client` constructor accepts an array of options. All given options will
be passed through to the underlying `SoapClient`. However, not all options
Expand Down
7 changes: 4 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@
* }
* ```
*
* > Note that if you have `ext-xdebug` loaded, this may halt with a fatal
* error instead of throwing a `SoapFault`. It is not recommended to use this
* extension in production, so this should only ever affect test environments.
* > Note that if you have an old version of `ext-xdebug` < 2.7 loaded, this may
* halt with a fatal error instead of throwing a `SoapFault`. It is not
* recommended to use this extension in production, so this should only ever
* affect test environments.
*
* The `Client` constructor accepts an array of options. All given options will
* be passed through to the underlying `SoapClient`. However, not all options
Expand Down
16 changes: 7 additions & 9 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,25 @@

class ClientTest extends TestCase
{

/**
* @expectedException SoapFault
*/
public function testConstructorThrowsWhenUrlIsInvalid()
{
if (extension_loaded('xdebug')) {
$this->markTestSkipped('Invalid WSDL causes a fatal error when ext-xdebug is loaded');
if (extension_loaded('xdebug') && phpversion('xdebug') < 2.7) {
$this->markTestSkipped('Invalid WSDL causes a fatal error when ext-xdebug < 2.7 is loaded');
}

$browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock();
$browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf();
$browser->expects($this->once())->method('withFollowRedirects')->willReturnSelf();

$wsdl = 'invalid';

$client = new Client($browser, $wsdl);
$this->expectException(\SoapFault::class);
new Client($browser, $wsdl);
}

public function testNonWsdlClientReturnsSameLocationOptionForAnyFunction()
{
$browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock();

$browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf();
$browser->expects($this->once())->method('withFollowRedirects')->willReturnSelf();

Expand All @@ -39,7 +38,6 @@ public function testNonWsdlClientReturnsSameLocationOptionForAnyFunction()
public function testNonWsdlClientReturnsNoTypesAndFunctions()
{
$browser = $this->getMockBuilder('React\Http\Browser')->disableOriginalConstructor()->getMock();

$browser->expects($this->once())->method('withRejectErrorResponse')->willReturnSelf();
$browser->expects($this->once())->method('withFollowRedirects')->willReturnSelf();

Expand Down
40 changes: 14 additions & 26 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ public function testBlzServiceWithRedirectLocationRejectsWithRuntimeException()
$api = new Proxy($this->client);
$promise = $api->getBank('a');

$this->setExpectedException('RuntimeException', 'redirects');
$result = Block\await($promise, $this->loop);
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('redirects');
Block\await($promise, $this->loop);
}

public function testBlzServiceWithInvalidBlzRejectsWithSoapFault()
Expand All @@ -144,7 +145,8 @@ public function testBlzServiceWithInvalidBlzRejectsWithSoapFault()

$promise = $api->getBank(array('blz' => 'invalid'));

$this->setExpectedException('SoapFault', 'Keine Bank zur BLZ invalid gefunden!');
$this->expectException(\SoapFault::class);
$this->expectExceptionMessage('Keine Bank zur BLZ invalid gefunden!');
Block\await($promise, $this->loop);
}

Expand All @@ -154,7 +156,8 @@ public function testBlzServiceWithInvalidMethodRejectsWithSoapFault()

$promise = $api->doesNotExist();

$this->setExpectedException('SoapFault', 'Function ("doesNotExist") is not a valid method for this service');
$this->expectException(\SoapFault::class);
$this->expectExceptionMessage('Function ("doesNotExist") is not a valid method for this service');
Block\await($promise, $this->loop);
}

Expand All @@ -165,7 +168,8 @@ public function testCancelMethodRejectsWithRuntimeException()
$promise = $api->getBank(array('blz' => '12070000'));
$promise->cancel();

$this->setExpectedException('RuntimeException', 'cancelled');
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('cancelled');
Block\await($promise, $this->loop);
}

Expand All @@ -179,7 +183,8 @@ public function testTimeoutRejectsWithRuntimeException()

$promise = $api->getBank(array('blz' => '12070000'));

$this->setExpectedException('RuntimeException', 'timed out');
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('timed out');
Block\await($promise, $this->loop);
}

Expand All @@ -196,13 +201,13 @@ public function testGetLocationForFunctionNumber()

public function testGetLocationOfUnknownFunctionNameFails()
{
$this->setExpectedException('SoapFault');
$this->expectException(\SoapFault::class);
$this->client->getLocation('unknown');
}

public function testGetLocationForUnknownFunctionNumberFails()
{
$this->setExpectedException('SoapFault');
$this->expectException(\SoapFault::class);
$this->assertEquals('http://www.thomas-bayer.com/axis2/services/BLZService', $this->client->getLocation(100));
}

Expand Down Expand Up @@ -230,7 +235,7 @@ public function testWithLocationInvalidRejectsWithRuntimeException()

$promise = $api->getBank(array('blz' => '12070000'));

$this->setExpectedException('RuntimeException');
$this->expectException(\RuntimeException::class);
Block\await($promise, $this->loop);
}

Expand All @@ -257,21 +262,4 @@ public function assertIsTypeObject($actual)
$this->assertIsObject($actual);
}
}

public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null)
{
if (method_exists($this, 'expectException')) {
// PHPUnit 5+
$this->expectException($exception);
if ($exceptionMessage !== '') {
$this->expectExceptionMessage($exceptionMessage);
}
if ($exceptionCode !== null) {
$this->expectExceptionCode($exceptionCode);
}
} else {
// legacy PHPUnit 4
parent::setExpectedException($exception, $exceptionMessage, $exceptionCode);
}
}
}
20 changes: 2 additions & 18 deletions tests/Protocol/ClientDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class ClientDecoderTest extends TestCase
public function testDecodeThrowsSoapFaultForInvalidResponse()
{
$decoder = new ClientDecoder(null, array('location' => '1', 'uri' => '2'));
$this->setExpectedException('SoapFault');

$this->expectException(\SoapFault::class);
$decoder->decode('anything', 'invalid');
}

Expand All @@ -30,21 +31,4 @@ public function testDecodeMessageToObjectNonWsdl()

$this->assertEquals($expected, $res);
}

public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null)
{
if (method_exists($this, 'expectException')) {
// PHPUnit 5+
$this->expectException($exception);
if ($exceptionMessage !== '') {
$this->expectExceptionMessage($exceptionMessage);
}
if ($exceptionCode !== null) {
$this->expectExceptionCode($exceptionCode);
}
} else {
// legacy PHPUnit 4
parent::setExpectedException($exception, $exceptionMessage, $exceptionCode);
}
}
}
16 changes: 6 additions & 10 deletions tests/Protocol/ClientEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,23 @@ public function testEncodeCreatesRequestForNonWsdlRpcFunctionWithSoapV12()
$this->assertFalse($request->hasHeader('SOAPAction'));
}

/**
* @expectedException SoapFault
*/
public function testConstructorThrowsWhenUrlIsInvalid()
{
if (extension_loaded('xdebug')) {
$this->markTestSkipped('Invalid WSDL causes a fatal error when ext-xdebug is loaded');
if (extension_loaded('xdebug') && phpversion('xdebug') < 2.7) {
$this->markTestSkipped('Invalid WSDL causes a fatal error when ext-xdebug < 2.7 is loaded');
}

$this->expectException(\SoapFault::class);
new ClientEncoder('invalid');
}

/**
* @expectedException SoapFault
*/
public function testConstructorThrowsWhenNonWsdlDoesNotDefineLocationAndUri()
{
if (extension_loaded('xdebug')) {
$this->markTestSkipped('Invalid non-WSDL mode causes a fatal error when ext-xdebug is loaded');
if (extension_loaded('xdebug') && phpversion('xdebug') < 2.7) {
$this->markTestSkipped('Invalid non-WSDL mode causes a fatal error when ext-xdebug < 2.7 is loaded');
}

$this->expectException(\SoapFault::class);
new ClientEncoder(null);
}

Expand Down