ProcessableExceptionTest.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Paypal\Test\Unit\Model\Api;
  7. use Magento\Paypal\Model\Api\ProcessableException;
  8. class ProcessableExceptionTest extends \PHPUnit\Framework\TestCase
  9. {
  10. const UNKNOWN_CODE = 10411;
  11. /**
  12. * @var ProcessableException
  13. */
  14. private $model;
  15. /**
  16. * @param int $code
  17. * @param string $msg
  18. * @return void
  19. * @dataProvider getUserMessageDataProvider
  20. */
  21. public function testGetUserMessage($code, $msg)
  22. {
  23. $this->model = new ProcessableException(__($msg), null, $code);
  24. $this->assertEquals($msg, $this->model->getUserMessage());
  25. }
  26. /**
  27. * @return array
  28. */
  29. public function getUserMessageDataProvider()
  30. {
  31. return [
  32. [
  33. ProcessableException::API_INTERNAL_ERROR,
  34. "I'm sorry - but we were not able to process your payment. "
  35. . "Please try another payment method or contact us so we can assist you.",
  36. ],
  37. [
  38. ProcessableException::API_UNABLE_PROCESS_PAYMENT_ERROR_CODE,
  39. "I'm sorry - but we were not able to process your payment. "
  40. . "Please try another payment method or contact us so we can assist you."
  41. ],
  42. [
  43. ProcessableException::API_COUNTRY_FILTER_DECLINE,
  44. "I'm sorry - but we are not able to complete your transaction. Please contact us so we can assist you."
  45. ],
  46. [
  47. ProcessableException::API_MAXIMUM_AMOUNT_FILTER_DECLINE,
  48. "I'm sorry - but we are not able to complete your transaction. Please contact us so we can assist you."
  49. ],
  50. [
  51. ProcessableException::API_OTHER_FILTER_DECLINE,
  52. "I'm sorry - but we are not able to complete your transaction. Please contact us so we can assist you."
  53. ],
  54. [
  55. ProcessableException::API_ADDRESS_MATCH_FAIL,
  56. 'A match of the Shipping Address City, State, and Postal Code failed.'
  57. ],
  58. [
  59. self::UNKNOWN_CODE,
  60. "We can't place the order."
  61. ]
  62. ];
  63. }
  64. }