From 5777fb478c485fcf9992aedafa07ae7427ea652b Mon Sep 17 00:00:00 2001
From: Matt Trefilek <matthew.trefilek@wisc.edu>
Date: Fri, 6 Oct 2017 16:44:32 -0500
Subject: [PATCH] wrap in array if needed

---
 src/main/edu/wisc/doit/RpcNetidClientSoap.php            | 4 ++--
 .../edu/wisc/doit/RpcNetidStructValidationResponse.php   | 9 +++++++--
 src/test/RpcNetidClientSoapTest.php                      | 2 +-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/main/edu/wisc/doit/RpcNetidClientSoap.php b/src/main/edu/wisc/doit/RpcNetidClientSoap.php
index d325241..1680ab2 100644
--- a/src/main/edu/wisc/doit/RpcNetidClientSoap.php
+++ b/src/main/edu/wisc/doit/RpcNetidClientSoap.php
@@ -297,11 +297,11 @@ class RpcNetidClientSoap implements RpcNetidClient {
 		}
 		
 		if( $result->result === 400){
-			return new RpcNetidStructValidationResponse(false, array($result->Reasons->Reason) );
+			return new RpcNetidStructValidationResponse(false, $result->Reasons->Reason );
 		}
 		
 		if( $result->result === 401){
-			return new RpcNetidStructValidationResponse(false, array($result->Reasons->Reason) );
+			return new RpcNetidStructValidationResponse(false, $result->Reasons->Reason );
 		}
 		
 		throw new RpcNetidClientSoapException("Unexpected status code: {$result->result}",
diff --git a/src/main/edu/wisc/doit/RpcNetidStructValidationResponse.php b/src/main/edu/wisc/doit/RpcNetidStructValidationResponse.php
index 2301a03..eb68ef0 100644
--- a/src/main/edu/wisc/doit/RpcNetidStructValidationResponse.php
+++ b/src/main/edu/wisc/doit/RpcNetidStructValidationResponse.php
@@ -25,7 +25,12 @@ class RpcNetidStructValidationResponse {
 	 * @param array $reasons the array of a Reason for why the SOAP Call failed
 	 */
 	function __construct( $isValid, array $reasons ) {
-		$this->setIsValid( $isValid );
+	    if(gettype($reasons) == "array") {
+            $this->setIsValid( $isValid );
+        } else {
+            $this->setIsValid(array( $isValid) );
+        }
+
 		$this->setReasons( $reasons );
 	}
 	
@@ -45,7 +50,7 @@ class RpcNetidStructValidationResponse {
 	/**
 	 * @return string  the reason for a password being invalid
 	 */
-	function getReasons() { return $this->reasons[0]; }
+	function getReasons() { return $this->reasons; }
 	
 	/**
 	 * @param string[] $reason  the reason for a password being invalid
diff --git a/src/test/RpcNetidClientSoapTest.php b/src/test/RpcNetidClientSoapTest.php
index 44dcd85..de03d7e 100644
--- a/src/test/RpcNetidClientSoapTest.php
+++ b/src/test/RpcNetidClientSoapTest.php
@@ -626,7 +626,7 @@ class RpcNetidClientSoapTest extends PHPUnit\Framework\TestCase {
 		
 		$this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned );
 		$this->assertFalse( $returned->getIsValid() );
-		$this->assertEquals( RpcNetidStructValidationResponse::REASON_NEEDS_WISCARD, $returned->getReasons() );
+		$this->assertContains( RpcNetidStructValidationResponse::REASON_NEEDS_WISCARD, $returned->getReasons() );
 		
 	}
 	
-- 
GitLab