| 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 testIsContactExportEnabledFalse() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $this->scopeConfig->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             ->method('isSetFlag') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             ->with('activecampaign/export/contact_enabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |             ->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         $this->assertFalse($this->config->isContactExportEnabled()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     public function testIsContactExportEnabledTrue() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         $this->scopeConfig->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |             ->method('isSetFlag') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             ->with('activecampaign/export/contact_enabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |             ->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         $this->assertTrue($this->config->isContactExportEnabled()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     public function testIsCustomerExportEnabledFalse() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         $this->scopeConfig->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             ->method('isSetFlag') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |             ->with('activecampaign/export/customer_enabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |             ->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         $this->assertFalse($this->config->isCustomerExportEnabled()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     public function testIsCustomerExportEnabledTrue() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         $this->scopeConfig->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             ->method('isSetFlag') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             ->with('activecampaign/export/customer_enabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             ->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         $this->assertTrue($this->config->isCustomerExportEnabled()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     public function testIsOrderExportEnabledFalse() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         $this->scopeConfig->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |             ->method('isSetFlag') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |             ->with('activecampaign/export/order_enabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |             ->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |         $this->assertFalse($this->config->isOrderExportEnabled()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 147 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  |     public function testIsOrderExportEnabledTrue() | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  |         $this->scopeConfig->expects($this->once()) | 
            
                                                                        
                            
            
                                    
            
            
                | 151 |  |  |             ->method('isSetFlag') | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  |             ->with('activecampaign/export/order_enabled') | 
            
                                                                        
                            
            
                                    
            
            
                | 153 |  |  |             ->willReturn(true); | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 155 |  |  |         $this->assertTrue($this->config->isOrderExportEnabled()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     public function testIsAbandonedCartExportEnabledFalse() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         $this->scopeConfig->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |             ->method('isSetFlag') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |             ->with('activecampaign/export/abandoned_cart_enabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |             ->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         $this->assertFalse($this->config->isAbandonedCartExportEnabled()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     public function testIsAbandonedCartExportEnabledTrue() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         $this->scopeConfig->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |             ->method('isSetFlag') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |             ->with('activecampaign/export/abandoned_cart_enabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             ->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |         $this->assertTrue($this->config->isAbandonedCartExportEnabled()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 177 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 178 |  |  |  | 
            
                        
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.