Skip to content

Commit

Permalink
Use expectException instead of setExpectedException
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh committed May 14, 2018
1 parent 9c02909 commit f48c3c8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 39 deletions.
27 changes: 10 additions & 17 deletions tests/Message/ExpressAuthorizeRequestTest.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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');
}
Expand Down
21 changes: 8 additions & 13 deletions tests/Message/ExpressInContextAuthorizeRequestTest.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down
15 changes: 6 additions & 9 deletions tests/Message/ExpressTransactionSearchRequestTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Omnipay\PayPal\Message;

use Omnipay\Common\Exception\InvalidRequestException;
use Omnipay\Tests\TestCase;

class ExpressTransactionSearchRequestTest extends TestCase
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down

0 comments on commit f48c3c8

Please sign in to comment.