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