| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | namespace CommerceLeague\ActiveCampaign\Test\Observer\Customer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use CommerceLeague\ActiveCampaign\MessageQueue\Topics; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use CommerceLeague\ActiveCampaign\Observer\Customer\ExportCustomerObserver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Magento\Customer\Model\Customer as MagentoCustomer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Magento\Framework\Event; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Magento\Framework\Event\Observer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Magento\Framework\MessageQueue\PublisherInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use PHPUnit\Framework\MockObject\MockObject; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use PHPUnit\Framework\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | class ExportCustomerObserverTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * @var MockObject|ConfigHelper | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     protected $configHelper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * @var MockObject|PublisherInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     protected $publisher; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * @var MockObject|Observer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     protected $observer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      * @var MockObject|Event | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     protected $event; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * @var MockObject|MagentoCustomer | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     protected $magentoCustomer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @var ExportCustomerObserver | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     protected $exportCustomerObserver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     protected function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         $this->configHelper = $this->createMock(ConfigHelper::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         $this->publisher = $this->createMock(PublisherInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $this->observer = $this->createMock(Observer::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $this->event = $this->createMock(Event::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $this->magentoCustomer = $this->createMock(MagentoCustomer::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $this->exportCustomerObserver = new ExportCustomerObserver( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             $this->configHelper, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |             $this->publisher | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     public function testExecuteApiDisabled() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $this->configHelper->expects($this->once()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             ->method('isEnabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             ->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $this->observer->expects($this->never()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |             ->method('getEvent'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         $this->exportCustomerObserver->execute($this->observer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |     public function testExecuteCustomerExportDisabled() | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |         $this->configHelper->expects($this->once()) | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |             ->method('isEnabled') | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |             ->willReturn(true); | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |         $this->configHelper->expects($this->once()) | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |             ->method('isCustomerExportEnabled') | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |             ->willReturn(false); | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |         $this->observer->expects($this->never()) | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |             ->method('getEvent'); | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |         $this->exportCustomerObserver->execute($this->observer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     public function testExecute() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         $magentoCustomerId = 123; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         $this->configHelper->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             ->method('isEnabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             ->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $this->configHelper->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             ->method('isCustomerExportEnabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             ->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $this->observer->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             ->method('getEvent') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             ->willReturn($this->event); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         $this->event->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             ->method('getData') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             ->with('customer') | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |             ->willReturn($this->magentoCustomer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         $this->magentoCustomer->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             ->method('getId') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             ->willReturn($magentoCustomerId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |         $this->publisher->expects($this->once()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             ->method('publish') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |                 Topics::CUSTOMER_CUSTOMER_EXPORT, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |                 json_encode(['magento_customer_id' => $magentoCustomerId]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         $this->exportCustomerObserver->execute($this->observer); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 126 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 127 |  |  |  | 
            
                        
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.