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