diff --git a/.gitignore b/.gitignore index f12ca75fffa864ba5f9d3d8f07c0e4288d88b907..dd1e8f5de6470c75fd340252465aec249e527345 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /.project /.settings /.vagrant +/.idea /composer.lock /vendor /composer.phar diff --git a/src/main/edu/wisc/doit/RpcNetidClientSoap.php b/src/main/edu/wisc/doit/RpcNetidClientSoap.php index 81a8c1a0f37849ab95ac38098fca554727f327f2..7f72644f3776ba64038f17c0d2a03452c65cfbe8 100644 --- a/src/main/edu/wisc/doit/RpcNetidClientSoap.php +++ b/src/main/edu/wisc/doit/RpcNetidClientSoap.php @@ -131,20 +131,20 @@ class RpcNetidClientSoap implements RpcNetidClient { return new RpcNetidStructValidationResponse(false, array()); break; case 401: - throw new RpcNetidClientSoapException("Web service returned 401: invalid input parameters", - RpcNetidClientSoapException::UNEXPECTED_STATUS_CODE ); + return new RpcNetidStructValidationResponse( false, array("Web service returned 401: invalid input + parameters")); break; case 402: - throw new RpcNetidClientSoapException("Web service returned 402: no PVI found for uid", - RpcNetidClientSoapException::UNEXPECTED_STATUS_CODE ); + return new RpcNetidStructValidationResponse( false, array("Web service returned 402: no PVI found for + uid") ); break; case 403: - throw new RpcNetidClientSoapException("Web service returned 403: no LOA found for uid", - RpcNetidClientSoapException::UNEXPECTED_STATUS_CODE ); + return new RpcNetidStructValidationResponse( false, array("Web service returned 403: no LOA found for + uid") ); break; case 404: - throw new RpcNetidClientSoapException("Web service returned 404: no Wiscard eligibility data found for uid", - RpcNetidClientSoapException::UNEXPECTED_STATUS_CODE ); + return new RpcNetidStructValidationResponse( false, array("Web service returned 404: no Wiscard + eligibility data found for uid")); break; case 405: return new RpcNetidStructValidationResponse(false, array(RpcNetidStructValidationResponse::REASON_NEEDS_WISCARD ) ); diff --git a/src/test/RpcNetidClientSoapTest.php b/src/test/RpcNetidClientSoapTest.php index 04bb59d0011d2d9257223dada9d8e524be802e01..06e6761b3eda7ee89d829e167ec1f94effd4dd17 100644 --- a/src/test/RpcNetidClientSoapTest.php +++ b/src/test/RpcNetidClientSoapTest.php @@ -564,66 +564,66 @@ class RpcNetidClientSoapTest extends PHPUnit_Framework_TestCase { } /** - * @test throws exception if web service returns 401 (invalid parameters) - * @expectedException edu\wisc\doit\RpcNetidClientSoapException - * @expectedExceptionCode 100 + * @test returns false if web service returns 401 (invalid parameters) */ - function checkLOA_401_throws() { + function checkLOA_401_returns_false() { $result = new stdClass(); $result->result = 401; $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $client = new RpcNetidClientSoap($this->mockSoapClient); - $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); + $this->assertFalse( $returned->getIsValid() ); } /** - * @test throws exception if web service returns 402 (No PVI found for UID) - * @expectedException edu\wisc\doit\RpcNetidClientSoapException - * @expectedExceptionCode 100 + * @test returns false if web service returns 402 (No PVI found for UID) */ - function checkLOA_402_throws() { + function checkLOA_402_returns_false() { $result = new stdClass(); $result->result = 402; $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $client = new RpcNetidClientSoap($this->mockSoapClient); - $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); - + $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); + $this->assertFalse( $returned->getIsValid() ); + } /** - * @test throws exception if web service returns 403 (No LOA found for UID) - * @expectedException edu\wisc\doit\RpcNetidClientSoapException - * @expectedExceptionCode 100 + * @test returns false if web service returns 403 (No LOA found for UID) */ - function checkLOA_403_throws() { + function checkLOA_403_returns_false() { $result = new stdClass(); $result->result = 403; $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $client = new RpcNetidClientSoap($this->mockSoapClient); - $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); + $this->assertFalse( $returned->getIsValid() ); } /** - * @test throws exception if web service returns 404 (No Wiscard eligibility found for user) - * @expectedException edu\wisc\doit\RpcNetidClientSoapException - * @expectedExceptionCode 100 + * @test returns false if web service returns 404 (No Wiscard eligibility found for user) */ - function checkLOA_404_throws() { + function checkLOA_404_returns_false() { $result = new stdClass(); $result->result = 404; $this->mockSoapClient->expects($this->any())->method('checkLOA')->will($this->returnValue($result)); $client = new RpcNetidClientSoap($this->mockSoapClient); - $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $returned = $client->checkLOA( "jsmith", new \DateTime(), 12345678901 ); + $this->assertInstanceOf('edu\wisc\doit\RpcNetidStructValidationResponse', $returned ); + $this->assertFalse( $returned->getIsValid() ); }