|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
/** |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace CommerceLeague\ActiveCampaign\Test\Unit\Service; |
|
7
|
|
|
|
|
8
|
|
|
use CommerceLeague\ActiveCampaign\MessageQueue\Topics; |
|
9
|
|
|
use CommerceLeague\ActiveCampaign\Service\ExportCustomerService; |
|
10
|
|
|
use Magento\Customer\Model\Customer; |
|
11
|
|
|
use Magento\Framework\MessageQueue\PublisherInterface; |
|
12
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
|
13
|
|
|
use PHPUnit\Framework\TestCase; |
|
14
|
|
|
use CommerceLeague\ActiveCampaign\Gateway\Request\CustomerBuilder as CustomerRequestBuilder; |
|
15
|
|
|
|
|
16
|
|
|
class ExportCustomerServiceTest extends TestCase |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @var MockObject|CustomerRequestBuilder |
|
20
|
|
|
*/ |
|
21
|
|
|
protected $customerRequestBuilder; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var MockObject|PublisherInterface |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $publisher; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var ExportCustomerService |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $exportCustomerService; |
|
32
|
|
|
|
|
33
|
|
|
protected function setUp() |
|
34
|
|
|
{ |
|
35
|
|
|
$this->customerRequestBuilder = $this->createMock(CustomerRequestBuilder::class); |
|
36
|
|
|
$this->publisher = $this->createMock(PublisherInterface::class); |
|
37
|
|
|
$this->exportCustomerService = new ExportCustomerService( |
|
38
|
|
|
$this->customerRequestBuilder, |
|
39
|
|
|
$this->publisher |
|
40
|
|
|
); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function testExport() |
|
44
|
|
|
{ |
|
45
|
|
|
/** @var MockObject|Customer $magentoCustomer */ |
|
46
|
|
|
$magentoCustomer = $this->createMock(Customer::class); |
|
47
|
|
|
|
|
48
|
|
|
$magentoCustomerId = 123; |
|
49
|
|
|
$request = ['request']; |
|
50
|
|
|
|
|
51
|
|
|
$magentoCustomer->expects($this->once()) |
|
52
|
|
|
->method('getId') |
|
53
|
|
|
->willReturn($magentoCustomerId); |
|
54
|
|
|
|
|
55
|
|
|
$this->customerRequestBuilder->expects($this->once()) |
|
|
|
|
|
|
56
|
|
|
->method('build') |
|
57
|
|
|
->with($magentoCustomer) |
|
58
|
|
|
->willReturn($request); |
|
59
|
|
|
|
|
60
|
|
|
$this->publisher->expects($this->once()) |
|
|
|
|
|
|
61
|
|
|
->method('publish') |
|
62
|
|
|
->with( |
|
63
|
|
|
Topics::CUSTOMER_EXPORT, |
|
64
|
|
|
json_encode(['magento_customer_id' => $magentoCustomerId, 'request' => $request]) |
|
65
|
|
|
); |
|
66
|
|
|
|
|
67
|
|
|
$this->exportCustomerService->export($magentoCustomer); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.