From cffd4de6a820149ad68a7b804515e7dd7593b423 Mon Sep 17 00:00:00 2001
From: Andrew Hoffmann <andrew.hoffmann@wisc.edu>
Date: Wed, 8 Jul 2015 15:34:11 -0500
Subject: [PATCH] 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
---
 src/main/edu/wisc/doit/RpcNetidClientSoap.php    | 15 +++++----------
 src/test/RpcNetidClientSoapTest.php              | 16 ----------------
 .../integration-tests/RpcNetidClientSoapIT.php   |  6 ++++++
 3 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/src/main/edu/wisc/doit/RpcNetidClientSoap.php b/src/main/edu/wisc/doit/RpcNetidClientSoap.php
index 85422d8..0556dde 100644
--- a/src/main/edu/wisc/doit/RpcNetidClientSoap.php
+++ b/src/main/edu/wisc/doit/RpcNetidClientSoap.php
@@ -343,18 +343,13 @@ class RpcNetidClientSoap implements RpcNetidClient {
 
 		$result = $this->getSoapClient()->ping([]);
 
-		if ( $result->result === 200 ) {
-			if ( isset( $result->version ) ) {
-				return $result->version;
-			} else {
-				throw new RpcNetidClientSoapException("version not returned by web service",
-					RpcNetidClientSoapException::UNEXPECTED_RESPONSE);
-			}
+		if ( isset( $result->version ) ) {
+			return $result->version;
+		} else {
+			throw new RpcNetidClientSoapException("version not returned by web service",
+				RpcNetidClientSoapException::UNEXPECTED_RESPONSE);
 		}
 
-		throw new RpcNetidClientSoapException("Unexpected status code: {$result->result}",
-			RpcNetidClientSoapException::UNEXPECTED_STATUS_CODE );
-
 	}
 	
 	/**
diff --git a/src/test/RpcNetidClientSoapTest.php b/src/test/RpcNetidClientSoapTest.php
index 060ef83..45332f0 100644
--- a/src/test/RpcNetidClientSoapTest.php
+++ b/src/test/RpcNetidClientSoapTest.php
@@ -667,7 +667,6 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
 	 */
 	function ping_200_returns_version() {
 		$result = new stdClass();
-		$result->result = 200;
 		$result->version = "1.0";
 
 		$this->mockSoapClient->expects($this->any())->method('ping')->will($this->returnValue($result));
@@ -675,20 +674,6 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
 		$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
 	 * @expectedException \edu\wisc\doit\RpcNetidClientSoapException
@@ -696,7 +681,6 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase {
 	 */
 	function ping_no_version_throws() {
 		$result = new stdClass();
-		$result->result = 200;
 
 		$this->mockSoapClient->expects($this->any())->method('ping')->will($this->returnValue($result));
 		$client = new RpcNetidClientSoap($this->mockSoapClient);
diff --git a/src/test/integration-tests/RpcNetidClientSoapIT.php b/src/test/integration-tests/RpcNetidClientSoapIT.php
index b85a885..1870d44 100644
--- a/src/test/integration-tests/RpcNetidClientSoapIT.php
+++ b/src/test/integration-tests/RpcNetidClientSoapIT.php
@@ -259,5 +259,11 @@ class RpcNetidClientSoapIT extends PHPUnit_Framework_TestCase {
 		$this->assertFalse( $result->getIsValid() );
 		$this->assertNotEmpty( $result->getReasons() );
 	}
+
+	/** @test */
+	public function ping_control() {
+		$result = self::$client->ping();
+		$this->assertNotEmpty( $result );
+	}
 	
 }
-- 
GitLab