|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
*/ |
|
4
|
|
|
|
|
5
|
|
|
namespace CommerceLeague\ActiveCampaign\Test\Unit\Model\ActiveCampaign; |
|
6
|
|
|
|
|
7
|
|
|
use CommerceLeague\ActiveCampaign\Api\Data\ContactInterface; |
|
8
|
|
|
use CommerceLeague\ActiveCampaign\Model\ActiveCampaign\Contact; |
|
9
|
|
|
use CommerceLeague\ActiveCampaign\Model\ResourceModel\ActiveCampaign\Contact as ContactResource; |
|
10
|
|
|
use Magento\Framework\Model\Context; |
|
11
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
|
12
|
|
|
use PHPUnit\Framework\TestCase; |
|
13
|
|
|
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; |
|
14
|
|
|
|
|
15
|
|
|
class ContactTest extends TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var MockObject|Context |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $context; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var MockObject|ContactResource |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $resource; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var Contact |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $contact; |
|
31
|
|
|
|
|
32
|
|
|
protected function setUp() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->context = $this->createMock(Context::class); |
|
35
|
|
|
$this->resource = $this->createMock(ContactResource::class); |
|
36
|
|
|
|
|
37
|
|
|
$this->contact = (new ObjectManager($this))->getObject( |
|
38
|
|
|
Contact::class, |
|
39
|
|
|
[ |
|
40
|
|
|
'context' => $this->context, |
|
41
|
|
|
'resource' => $this->resource |
|
42
|
|
|
] |
|
43
|
|
|
); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testGetId() |
|
47
|
|
|
{ |
|
48
|
|
|
$entityId = 123; |
|
49
|
|
|
$this->contact->setData(ContactInterface::ENTITY_ID, $entityId); |
|
50
|
|
|
$this->assertEquals($entityId, $this->contact->getId()); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function testSetId() |
|
54
|
|
|
{ |
|
55
|
|
|
$entityId = 123; |
|
56
|
|
|
$this->contact->setId($entityId); |
|
57
|
|
|
$this->assertEquals($entityId, $this->contact->getData(ContactInterface::ENTITY_ID)); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function testGetEmail() |
|
61
|
|
|
{ |
|
62
|
|
|
$email = '[email protected]'; |
|
63
|
|
|
$this->contact->setData(ContactInterface::EMAIL, $email); |
|
64
|
|
|
$this->assertEquals($email, $this->contact->getEmail()); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function testSetEmail() |
|
68
|
|
|
{ |
|
69
|
|
|
$email = '[email protected]'; |
|
70
|
|
|
$this->contact->setEmail($email); |
|
71
|
|
|
$this->assertEquals($email, $this->contact->getData(ContactInterface::EMAIL)); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function testGetActiveCampaignId() |
|
75
|
|
|
{ |
|
76
|
|
|
$activeCampaignId = 123; |
|
77
|
|
|
$this->contact->setData(ContactInterface::ACTIVE_CAMPAIGN_ID, $activeCampaignId); |
|
78
|
|
|
$this->assertEquals($activeCampaignId, $this->contact->getActiveCampaignId()); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function testSetActiveCampaignId() |
|
82
|
|
|
{ |
|
83
|
|
|
$activeCampaignId = 123; |
|
84
|
|
|
$this->contact->setActiveCampaignId($activeCampaignId); |
|
85
|
|
|
$this->assertEquals($activeCampaignId, $this->contact->getData(ContactInterface::ACTIVE_CAMPAIGN_ID)); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function testGetCreatedAt() |
|
89
|
|
|
{ |
|
90
|
|
|
$createdAt = '2019-01-01 00:00:00'; |
|
91
|
|
|
$this->contact->setData(ContactInterface::CREATED_AT, $createdAt); |
|
92
|
|
|
$this->assertEquals($createdAt, $this->contact->getCreatedAt()); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
public function testSetCreatedAt() |
|
96
|
|
|
{ |
|
97
|
|
|
$createdAt = '2019-01-01 00:00:00'; |
|
98
|
|
|
$this->contact->setCreatedAt($createdAt); |
|
99
|
|
|
$this->assertEquals($createdAt, $this->contact->getData(ContactInterface::CREATED_AT)); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function testGetUpdatedAt() |
|
103
|
|
|
{ |
|
104
|
|
|
$updatedAt = '2019-01-01 00:00:00'; |
|
105
|
|
|
$this->contact->setData(ContactInterface::UPDATED_AT, $updatedAt); |
|
106
|
|
|
$this->assertEquals($updatedAt, $this->contact->getUpdatedAt()); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
public function testSetUpdatedAt() |
|
110
|
|
|
{ |
|
111
|
|
|
$updatedAt = '2019-01-01 00:00:00'; |
|
112
|
|
|
$this->contact->setUpdatedAt($updatedAt); |
|
113
|
|
|
$this->assertEquals($updatedAt, $this->contact->getData(ContactInterface::UPDATED_AT)); |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|