|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
*/ |
|
4
|
|
|
|
|
5
|
|
|
namespace CommerceLeague\ActiveCampaign\Test\Unit\Helper; |
|
6
|
|
|
|
|
7
|
|
|
use CommerceLeague\ActiveCampaign\Helper\Config; |
|
8
|
|
|
use Magento\Framework\App\Config\ScopeConfigInterface; |
|
9
|
|
|
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; |
|
10
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
|
11
|
|
|
use PHPUnit\Framework\TestCase; |
|
12
|
|
|
|
|
13
|
|
|
class ConfigTest extends TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @var MockObject|ScopeConfigInterface |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $scopeConfig; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @var Config |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $config; |
|
24
|
|
|
|
|
25
|
|
|
protected function setUp() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->scopeConfig = $this->createPartialMock( |
|
28
|
|
|
ScopeConfigInterface::class, |
|
29
|
|
|
['getValue', 'isSetFlag'] |
|
30
|
|
|
); |
|
31
|
|
|
|
|
32
|
|
|
$objectManager = new ObjectManager($this); |
|
33
|
|
|
|
|
34
|
|
|
$this->config = $objectManager->getObject( |
|
35
|
|
|
Config::class, |
|
36
|
|
|
[ |
|
37
|
|
|
'scopeConfig' => $this->scopeConfig |
|
38
|
|
|
] |
|
39
|
|
|
); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function testIsEnabledFalse() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->scopeConfig->expects($this->once()) |
|
|
|
|
|
|
45
|
|
|
->method('isSetFlag') |
|
46
|
|
|
->with('activecampaign/general/enabled') |
|
47
|
|
|
->willReturn(false); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertFalse($this->config->isEnabled()); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function testIsEnabledTrue() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->scopeConfig->expects($this->once()) |
|
55
|
|
|
->method('isSetFlag') |
|
56
|
|
|
->with('activecampaign/general/enabled') |
|
57
|
|
|
->willReturn(true); |
|
58
|
|
|
|
|
59
|
|
|
$this->assertTrue($this->config->isEnabled()); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function testGetApiUrl() |
|
63
|
|
|
{ |
|
64
|
|
|
$apiUrl = 'http://example.com'; |
|
65
|
|
|
|
|
66
|
|
|
$this->scopeConfig->expects($this->once()) |
|
67
|
|
|
->method('getValue') |
|
68
|
|
|
->with('activecampaign/general/api_url') |
|
69
|
|
|
->willReturn($apiUrl); |
|
70
|
|
|
|
|
71
|
|
|
$this->assertEquals($apiUrl, $this->config->getApiUrl()); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function testGetApiToken() |
|
75
|
|
|
{ |
|
76
|
|
|
$apiToken = 'API_TOKEN'; |
|
77
|
|
|
|
|
78
|
|
|
$this->scopeConfig->expects($this->once()) |
|
79
|
|
|
->method('getValue') |
|
80
|
|
|
->with('activecampaign/general/api_token') |
|
81
|
|
|
->willReturn($apiToken); |
|
82
|
|
|
|
|
83
|
|
|
$this->assertEquals($apiToken, $this->config->getApiToken()); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function testGetConnectionId() |
|
87
|
|
|
{ |
|
88
|
|
|
$connectionId = '123'; |
|
89
|
|
|
|
|
90
|
|
|
$this->scopeConfig->expects($this->once()) |
|
91
|
|
|
->method('getValue') |
|
92
|
|
|
->with('activecampaign/general/connection_id') |
|
93
|
|
|
->willReturn($connectionId); |
|
94
|
|
|
|
|
95
|
|
|
$this->assertEquals($connectionId, $this->config->getConnectionId()); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function getAbandonedCartExportAfter() |
|
99
|
|
|
{ |
|
100
|
|
|
$exportAfter = 15; |
|
101
|
|
|
|
|
102
|
|
|
$this->scopeConfig->expects($this->once()) |
|
103
|
|
|
->method('getValue') |
|
104
|
|
|
->with('activecampaign/abandoned_cart/export_after') |
|
105
|
|
|
->willReturn($exportAfter); |
|
106
|
|
|
|
|
107
|
|
|
$this->assertEquals($exportAfter, $this->config->getAbandonedCartExportAfter()); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|
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.