1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CommerceLeague\ActiveCampaign\Test\Unit\Gateway\Request; |
4
|
|
|
|
5
|
|
|
use CommerceLeague\ActiveCampaign\Gateway\Request\ContactRequestBuilder; |
6
|
|
|
use Magento\Customer\Model\Customer; |
7
|
|
|
use Magento\Newsletter\Model\Subscriber; |
8
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
*/ |
13
|
|
|
class ContactRequestBuilderTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var MockObject|Customer |
17
|
|
|
*/ |
18
|
|
|
protected $customer; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var MockObject|Subscriber |
22
|
|
|
*/ |
23
|
|
|
protected $subscriber; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var ContactRequestBuilder |
27
|
|
|
*/ |
28
|
|
|
protected $contactRequestBuilder; |
29
|
|
|
|
30
|
|
|
protected function setUp() |
31
|
|
|
{ |
32
|
|
|
$this->customer = $this->createMock(Customer::class); |
33
|
|
|
$this->subscriber = $this->createMock(Subscriber::class); |
34
|
|
|
$this->contactRequestBuilder = new ContactRequestBuilder(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testBuildWithCustomer() |
38
|
|
|
{ |
39
|
|
|
$email = '[email protected]'; |
40
|
|
|
$firstName = 'John'; |
41
|
|
|
$lasName = 'Doe'; |
42
|
|
|
|
43
|
|
|
$this->customer->expects($this->at(0)) |
44
|
|
|
->method('getData') |
|
|
|
|
45
|
|
|
->with('email') |
|
|
|
|
46
|
|
|
->willReturn($email); |
|
|
|
|
47
|
|
|
|
48
|
|
|
$this->customer->expects($this->at(1)) |
49
|
|
|
->method('getData') |
50
|
|
|
->with('firstname') |
51
|
|
|
->willReturn($firstName); |
52
|
|
|
|
53
|
|
|
$this->customer->expects($this->at(2)) |
54
|
|
|
->method('getData') |
55
|
|
|
->with('lastname') |
56
|
|
|
->willReturn($lasName); |
57
|
|
|
|
58
|
|
|
$this->customer->expects($this->exactly(3)) |
59
|
|
|
->method('getData'); |
60
|
|
|
|
61
|
|
|
$this->assertEquals( |
62
|
|
|
[ |
63
|
|
|
'email' => $email, |
64
|
|
|
'firstName' => $firstName, |
65
|
|
|
'lastName' => $lasName |
66
|
|
|
], |
67
|
|
|
$this->contactRequestBuilder->buildWithCustomer($this->customer) |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function testBuildWithSubscriber() |
72
|
|
|
{ |
73
|
|
|
$email = '[email protected]'; |
74
|
|
|
|
75
|
|
|
$this->subscriber->expects($this->once()) |
76
|
|
|
->method('getEmail') |
77
|
|
|
->willReturn($email); |
78
|
|
|
|
79
|
|
|
$this->assertEquals( |
80
|
|
|
[ |
81
|
|
|
'email' => $email |
82
|
|
|
], |
83
|
|
|
$this->contactRequestBuilder->buildWithSubscriber($this->subscriber) |
84
|
|
|
); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
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.