Skip to content

Commit f48c3c8

Browse files
committed
Use expectException instead of setExpectedException
1 parent 9c02909 commit f48c3c8

3 files changed

+24
-39
lines changed

tests/Message/ExpressAuthorizeRequestTest.php

+10-17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Omnipay\PayPal\Message;
44

55
use Omnipay\Common\CreditCard;
6+
use Omnipay\Common\Exception\InvalidRequestException;
67
use Omnipay\PayPal\Message\ExpressAuthorizeRequest;
78
use Omnipay\PayPal\Support\InstantUpdateApi\BillingAgreement;
89
use Omnipay\PayPal\Support\InstantUpdateApi\ShippingOption;
@@ -306,10 +307,8 @@ public function testDataWithCallbackAndNoDefaultShippingOption()
306307
'shippingOptions' => $shippingOptions,
307308
)));
308309

309-
$this->setExpectedException(
310-
'\Omnipay\Common\Exception\InvalidRequestException',
311-
'One of the supplied shipping options must be set as default'
312-
);
310+
$this->expectException(InvalidRequestException::class);
311+
$this->expectExceptionMessage('One of the supplied shipping options must be set as default');
313312

314313
$this->request->getData();
315314
}
@@ -321,10 +320,8 @@ public function testNoAmount()
321320

322321
$this->request->initialize($baseData);
323322

324-
$this->setExpectedException(
325-
'\Omnipay\Common\Exception\InvalidRequestException',
326-
'The amount parameter is required'
327-
);
323+
$this->expectException(InvalidRequestException::class);
324+
$this->expectExceptionMessage('The amount parameter is required');
328325

329326
$this->request->getData();
330327
}
@@ -337,10 +334,8 @@ public function testAmountButNoReturnUrl()
337334

338335
$this->request->initialize($baseData);
339336

340-
$this->setExpectedException(
341-
'\Omnipay\Common\Exception\InvalidRequestException',
342-
'The returnUrl parameter is required'
343-
);
337+
$this->expectException(InvalidRequestException::class);
338+
$this->expectExceptionMessage('The returnUrl parameter is required');
344339

345340
$this->request->getData();
346341
}
@@ -368,7 +363,7 @@ public function testBadCallbackConfiguration()
368363
// from the docblock on this exception -
369364
// Thrown when a request is invalid or missing required fields.
370365
// callback has been set but no shipping options so expect one of these:
371-
$this->setExpectedException('\Omnipay\Common\Exception\InvalidRequestException');
366+
$this->expectException(InvalidRequestException::class);
372367

373368
$this->request->getData();
374369
}
@@ -413,10 +408,8 @@ public function testGetDataWithBillingAgreementOptionalParameters()
413408
*/
414409
public function testGetDataWithBillingAgreementWrongPaymentType()
415410
{
416-
$this->setExpectedException(
417-
'\Omnipay\Common\Exception\InvalidRequestException',
418-
"The 'paymentType' parameter can be only 'Any' or 'InstantOnly'"
419-
);
411+
$this->expectException(InvalidRequestException::class);
412+
$this->expectExceptionMessage("The 'paymentType' parameter can be only 'Any' or 'InstantOnly'");
420413

421414
$billingAgreement = new BillingAgreement(false, 'Some Stuff', 'BadType', 'Some custom annotation');
422415
}

tests/Message/ExpressInContextAuthorizeRequestTest.php

+8-13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Omnipay\PayPal\Message;
44

55
use Omnipay\Common\CreditCard;
6+
use Omnipay\Common\Exception\InvalidRequestException;
67
use Omnipay\PayPal\Message\ExpressInContextAuthorizeRequest;
78
use Omnipay\PayPal\Support\InstantUpdateApi\ShippingOption;
89
use Omnipay\Tests\TestCase;
@@ -305,10 +306,8 @@ public function testDataWithCallbackAndNoDefaultShippingOption()
305306
'shippingOptions' => $shippingOptions,
306307
)));
307308

308-
$this->setExpectedException(
309-
'\Omnipay\Common\Exception\InvalidRequestException',
310-
'One of the supplied shipping options must be set as default'
311-
);
309+
$this->expectException(InvalidRequestException::class);
310+
$this->expectExceptionMessage('One of the supplied shipping options must be set as default');
312311

313312
$this->request->getData();
314313
}
@@ -320,10 +319,8 @@ public function testNoAmount()
320319

321320
$this->request->initialize($baseData);
322321

323-
$this->setExpectedException(
324-
'\Omnipay\Common\Exception\InvalidRequestException',
325-
'The amount parameter is required'
326-
);
322+
$this->expectException(InvalidRequestException::class);
323+
$this->expectExceptionMessage('The amount parameter is required');
327324

328325
$this->request->getData();
329326
}
@@ -336,10 +333,8 @@ public function testAmountButNoReturnUrl()
336333

337334
$this->request->initialize($baseData);
338335

339-
$this->setExpectedException(
340-
'\Omnipay\Common\Exception\InvalidRequestException',
341-
'The returnUrl parameter is required'
342-
);
336+
$this->expectException(InvalidRequestException::class);
337+
$this->expectExceptionMessage('The returnUrl parameter is required');
343338

344339
$this->request->getData();
345340
}
@@ -367,7 +362,7 @@ public function testBadCallbackConfiguration()
367362
// from the docblock on this exception -
368363
// Thrown when a request is invalid or missing required fields.
369364
// callback has been set but no shipping options so expect one of these:
370-
$this->setExpectedException('\Omnipay\Common\Exception\InvalidRequestException');
365+
$this->expectException(InvalidRequestException::class);
371366

372367
$this->request->getData();
373368
}

tests/Message/ExpressTransactionSearchRequestTest.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Omnipay\PayPal\Message;
44

5+
use Omnipay\Common\Exception\InvalidRequestException;
56
use Omnipay\Tests\TestCase;
67

78
class ExpressTransactionSearchRequestTest extends TestCase
@@ -73,10 +74,8 @@ public function testWithoutStartDate()
7374
{
7475
$this->request->initialize(array());
7576

76-
$this->setExpectedException(
77-
'\Omnipay\Common\Exception\InvalidRequestException',
78-
'The startDate parameter is required'
79-
);
77+
$this->expectException(InvalidRequestException::class);
78+
$this->expectExceptionMessage('The startDate parameter is required');
8079

8180
$this->request->getData();
8281
}
@@ -85,11 +84,9 @@ public function testAmountWithoutCurrency()
8584
{
8685
$this->request->setStartDate('2015-01-01');
8786
$this->request->setAmount(150.00);
88-
89-
$this->setExpectedException(
90-
'\Omnipay\Common\Exception\InvalidRequestException',
91-
'The currency parameter is required'
92-
);
87+
88+
$this->expectException(InvalidRequestException::class);
89+
$this->expectExceptionMessage('The currency parameter is required');
9390

9491
$this->request->getData();
9592
}

0 commit comments

Comments
 (0)