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