Skip to content
Snippets Groups Projects
Commit cffd4de6 authored by Andrew Hoffmann's avatar Andrew Hoffmann
Browse files

Created an integration test for ping(). found out it doesn't return a result...

Created an integration test for ping(). found out it doesn't return a result code, so I can only go off of the "version" string for success. Updated client accordingly.

ACCTREC-299
parent 8861ffbd
No related branches found
No related tags found
No related merge requests found
...@@ -343,18 +343,13 @@ class RpcNetidClientSoap implements RpcNetidClient { ...@@ -343,18 +343,13 @@ class RpcNetidClientSoap implements RpcNetidClient {
$result = $this->getSoapClient()->ping([]); $result = $this->getSoapClient()->ping([]);
if ( $result->result === 200 ) { if ( isset( $result->version ) ) {
if ( isset( $result->version ) ) { return $result->version;
return $result->version; } else {
} else { throw new RpcNetidClientSoapException("version not returned by web service",
throw new RpcNetidClientSoapException("version not returned by web service", RpcNetidClientSoapException::UNEXPECTED_RESPONSE);
RpcNetidClientSoapException::UNEXPECTED_RESPONSE);
}
} }
throw new RpcNetidClientSoapException("Unexpected status code: {$result->result}",
RpcNetidClientSoapException::UNEXPECTED_STATUS_CODE );
} }
/** /**
......
...@@ -667,7 +667,6 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { ...@@ -667,7 +667,6 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
*/ */
function ping_200_returns_version() { function ping_200_returns_version() {
$result = new stdClass(); $result = new stdClass();
$result->result = 200;
$result->version = "1.0"; $result->version = "1.0";
$this->mockSoapClient->expects($this->any())->method('ping')->will($this->returnValue($result)); $this->mockSoapClient->expects($this->any())->method('ping')->will($this->returnValue($result));
...@@ -675,20 +674,6 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { ...@@ -675,20 +674,6 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
$this->assertEquals( "1.0", $client->ping() ); $this->assertEquals( "1.0", $client->ping() );
} }
/**
* @test ping() throws exception if unexpected response code
* @expectedException \edu\wisc\doit\RpcNetidClientSoapException
* @expectedExceptionCode 100
*/
function ping_500_throws() {
$result = new stdClass();
$result->result = 500;
$this->mockSoapClient->expects($this->any())->method('ping')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient);
$client->ping();
}
/** /**
* @test throws exception if version is not supplied by web service * @test throws exception if version is not supplied by web service
* @expectedException \edu\wisc\doit\RpcNetidClientSoapException * @expectedException \edu\wisc\doit\RpcNetidClientSoapException
...@@ -696,7 +681,6 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { ...@@ -696,7 +681,6 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
*/ */
function ping_no_version_throws() { function ping_no_version_throws() {
$result = new stdClass(); $result = new stdClass();
$result->result = 200;
$this->mockSoapClient->expects($this->any())->method('ping')->will($this->returnValue($result)); $this->mockSoapClient->expects($this->any())->method('ping')->will($this->returnValue($result));
$client = new RpcNetidClientSoap($this->mockSoapClient); $client = new RpcNetidClientSoap($this->mockSoapClient);
......
...@@ -259,5 +259,11 @@ class RpcNetidClientSoapIT extends PHPUnit_Framework_TestCase { ...@@ -259,5 +259,11 @@ class RpcNetidClientSoapIT extends PHPUnit_Framework_TestCase {
$this->assertFalse( $result->getIsValid() ); $this->assertFalse( $result->getIsValid() );
$this->assertNotEmpty( $result->getReasons() ); $this->assertNotEmpty( $result->getReasons() );
} }
/** @test */
public function ping_control() {
$result = self::$client->ping();
$this->assertNotEmpty( $result );
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment