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
<?php
/**
* @copyright Vertex. All rights reserved. https://www.vertexinc.com/
* @author Mediotype https://www.mediotype.com/
*/
namespace Vertex\Tax\Test\Unit\Model\Vertex;
use Magento\Sales\Model\Order;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManagerInterface;
use Vertex\Tax\Model\ApiClient;
use Vertex\Tax\Test\Unit\TestCase;
class GetStoreIdTest extends TestCase
{
public function testInvoiceSuppliesDataFromOrder()
{
$mockOrder = $this->createPartialMock(Order::class, ['getStoreId']);
$storeId = uniqid('store-id-');
$mockOrder->expects($this->once())
->method('getStoreId')
->willReturn($storeId);
/** @var ApiClient $vertex */
$vertex = $this->getObject(ApiClient::class);
$result = $this->invokeInaccessibleMethod($vertex, 'getStoreId', $mockOrder);
$this->assertEquals($storeId, $result);
}
public function testNoOrderReturnsNull()
{
$storeId = uniqid('store-id-');
$storeMock = $this->createMock(Store::class);
$storeMock->method('getId')
->willReturn($storeId);
$storeManagerMock = $this->createMock(StoreManagerInterface::class);
$storeManagerMock->method('getStore')
->willReturn($storeMock);
/** @var ApiClient $vertex */
$vertex = $this->getObject(ApiClient::class, ['storeManager' => $storeManagerMock]);
$result = $this->invokeInaccessibleMethod($vertex, 'getStoreId', null);
$this->assertEquals($storeId, $result);
}
}