IncompleteCompanyAddressTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @copyright Vertex. All rights reserved. https://www.vertexinc.com/
  4. * @author Mediotype https://www.mediotype.com/
  5. */
  6. namespace Vertex\Tax\Test\Integration\ApiExceptions;
  7. use Vertex\Services\Quote\Request;
  8. use Vertex\Tax\Api\QuoteInterface;
  9. use Vertex\Tax\Test\Integration\TestCase;
  10. /**
  11. * Ensure that making an API Request with an incomplete company address results in a generic exception
  12. */
  13. class IncompleteCompanyAddressTest extends TestCase
  14. {
  15. /** @var QuoteInterface */
  16. private $quote;
  17. /**
  18. * @inheritdoc
  19. */
  20. protected function setUp()
  21. {
  22. parent::setUp();
  23. $om = $this->getObjectManager();
  24. // We're mocking the SOAP Response, as we don't want to hit the real API during testing
  25. $soapFactory = $this->getSoapFactory();
  26. $soap = $this->getMockBuilder(\SoapClient::class)
  27. ->disableOriginalConstructor()
  28. ->disableProxyingToOriginalMethods()
  29. ->setMethods(['CalculateTax60'])
  30. ->getMock();
  31. $soapFactory->setSoapClient($soap);
  32. $fault = new \SoapFault(
  33. 'soapenv:Client',
  34. 'The LocationRole being added is invalid. This might be due to an invalid location or an invalid'
  35. . ' address field. Make sure that the locationRole is valid, and try again.'
  36. );
  37. $soap->method('CalculateTax60')
  38. ->willThrowException($fault);
  39. $this->quote = $om->get(QuoteInterface::class);
  40. }
  41. /**
  42. * Ensure that making an API Request with an incomplete company address results in a generic exception
  43. *
  44. * @expectedException \Vertex\Exception\ApiException
  45. */
  46. public function testSomething()
  47. {
  48. $this->quote->request(new Request());
  49. }
  50. }