diff --git a/tests/Message/ExpressAuthorizeRequestTest.php b/tests/Message/ExpressAuthorizeRequestTest.php index 1b9b5fe..60ab238 100644 --- a/tests/Message/ExpressAuthorizeRequestTest.php +++ b/tests/Message/ExpressAuthorizeRequestTest.php @@ -3,6 +3,7 @@ namespace Omnipay\PayPal\Message; use Omnipay\Common\CreditCard; +use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\PayPal\Message\ExpressAuthorizeRequest; use Omnipay\PayPal\Support\InstantUpdateApi\BillingAgreement; use Omnipay\PayPal\Support\InstantUpdateApi\ShippingOption; @@ -306,10 +307,8 @@ public function testDataWithCallbackAndNoDefaultShippingOption() 'shippingOptions' => $shippingOptions, ))); - $this->setExpectedException( - '\Omnipay\Common\Exception\InvalidRequestException', - 'One of the supplied shipping options must be set as default' - ); + $this->expectException(InvalidRequestException::class); + $this->expectExceptionMessage('One of the supplied shipping options must be set as default'); $this->request->getData(); } @@ -321,10 +320,8 @@ public function testNoAmount() $this->request->initialize($baseData); - $this->setExpectedException( - '\Omnipay\Common\Exception\InvalidRequestException', - 'The amount parameter is required' - ); + $this->expectException(InvalidRequestException::class); + $this->expectExceptionMessage('The amount parameter is required'); $this->request->getData(); } @@ -337,10 +334,8 @@ public function testAmountButNoReturnUrl() $this->request->initialize($baseData); - $this->setExpectedException( - '\Omnipay\Common\Exception\InvalidRequestException', - 'The returnUrl parameter is required' - ); + $this->expectException(InvalidRequestException::class); + $this->expectExceptionMessage('The returnUrl parameter is required'); $this->request->getData(); } @@ -368,7 +363,7 @@ public function testBadCallbackConfiguration() // from the docblock on this exception - // Thrown when a request is invalid or missing required fields. // callback has been set but no shipping options so expect one of these: - $this->setExpectedException('\Omnipay\Common\Exception\InvalidRequestException'); + $this->expectException(InvalidRequestException::class); $this->request->getData(); } @@ -413,10 +408,8 @@ public function testGetDataWithBillingAgreementOptionalParameters() */ public function testGetDataWithBillingAgreementWrongPaymentType() { - $this->setExpectedException( - '\Omnipay\Common\Exception\InvalidRequestException', - "The 'paymentType' parameter can be only 'Any' or 'InstantOnly'" - ); + $this->expectException(InvalidRequestException::class); + $this->expectExceptionMessage("The 'paymentType' parameter can be only 'Any' or 'InstantOnly'"); $billingAgreement = new BillingAgreement(false, 'Some Stuff', 'BadType', 'Some custom annotation'); } diff --git a/tests/Message/ExpressInContextAuthorizeRequestTest.php b/tests/Message/ExpressInContextAuthorizeRequestTest.php index 8471fb0..017b0e9 100644 --- a/tests/Message/ExpressInContextAuthorizeRequestTest.php +++ b/tests/Message/ExpressInContextAuthorizeRequestTest.php @@ -3,6 +3,7 @@ namespace Omnipay\PayPal\Message; use Omnipay\Common\CreditCard; +use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\PayPal\Message\ExpressInContextAuthorizeRequest; use Omnipay\PayPal\Support\InstantUpdateApi\ShippingOption; use Omnipay\Tests\TestCase; @@ -305,10 +306,8 @@ public function testDataWithCallbackAndNoDefaultShippingOption() 'shippingOptions' => $shippingOptions, ))); - $this->setExpectedException( - '\Omnipay\Common\Exception\InvalidRequestException', - 'One of the supplied shipping options must be set as default' - ); + $this->expectException(InvalidRequestException::class); + $this->expectExceptionMessage('One of the supplied shipping options must be set as default'); $this->request->getData(); } @@ -320,10 +319,8 @@ public function testNoAmount() $this->request->initialize($baseData); - $this->setExpectedException( - '\Omnipay\Common\Exception\InvalidRequestException', - 'The amount parameter is required' - ); + $this->expectException(InvalidRequestException::class); + $this->expectExceptionMessage('The amount parameter is required'); $this->request->getData(); } @@ -336,10 +333,8 @@ public function testAmountButNoReturnUrl() $this->request->initialize($baseData); - $this->setExpectedException( - '\Omnipay\Common\Exception\InvalidRequestException', - 'The returnUrl parameter is required' - ); + $this->expectException(InvalidRequestException::class); + $this->expectExceptionMessage('The returnUrl parameter is required'); $this->request->getData(); } @@ -367,7 +362,7 @@ public function testBadCallbackConfiguration() // from the docblock on this exception - // Thrown when a request is invalid or missing required fields. // callback has been set but no shipping options so expect one of these: - $this->setExpectedException('\Omnipay\Common\Exception\InvalidRequestException'); + $this->expectException(InvalidRequestException::class); $this->request->getData(); } diff --git a/tests/Message/ExpressTransactionSearchRequestTest.php b/tests/Message/ExpressTransactionSearchRequestTest.php index c0164b5..0d8fd6c 100644 --- a/tests/Message/ExpressTransactionSearchRequestTest.php +++ b/tests/Message/ExpressTransactionSearchRequestTest.php @@ -2,6 +2,7 @@ namespace Omnipay\PayPal\Message; +use Omnipay\Common\Exception\InvalidRequestException; use Omnipay\Tests\TestCase; class ExpressTransactionSearchRequestTest extends TestCase @@ -73,10 +74,8 @@ public function testWithoutStartDate() { $this->request->initialize(array()); - $this->setExpectedException( - '\Omnipay\Common\Exception\InvalidRequestException', - 'The startDate parameter is required' - ); + $this->expectException(InvalidRequestException::class); + $this->expectExceptionMessage('The startDate parameter is required'); $this->request->getData(); } @@ -85,11 +84,9 @@ public function testAmountWithoutCurrency() { $this->request->setStartDate('2015-01-01'); $this->request->setAmount(150.00); - - $this->setExpectedException( - '\Omnipay\Common\Exception\InvalidRequestException', - 'The currency parameter is required' - ); + + $this->expectException(InvalidRequestException::class); + $this->expectExceptionMessage('The currency parameter is required'); $this->request->getData(); }