| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | namespace CommerceLeague\ActiveCampaign\Test\Unit\Cron; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use CommerceLeague\ActiveCampaign\Cron\ExportOmittedOrders; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use CommerceLeague\ActiveCampaign\MessageQueue\Topics; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use CommerceLeague\ActiveCampaign\Model\ResourceModel\Order\Collection as OrderCollection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use CommerceLeague\ActiveCampaign\Model\ResourceModel\Order\CollectionFactory as OrderCollectionFactory; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Magento\Framework\MessageQueue\PublisherInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use PHPUnit\Framework\MockObject\MockObject; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use PHPUnit\Framework\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | class ExportOmittedOrdersTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * @var MockObject|ConfigHelper | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     protected $configHelper; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * @var MockObject|OrderCollectionFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     protected $orderCollectionFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @var MockObject|OrderCollection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     protected $orderCollection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * @var MockObject|PublisherInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     protected $publisher; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      * @var ExportOmittedOrders | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     protected $exportOmittedOrders; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     protected function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $this->configHelper = $this->createMock(ConfigHelper::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         $this->orderCollectionFactory = $this->getMockBuilder(OrderCollectionFactory::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             ->disableOriginalConstructor() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             ->setMethods(['create']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             ->getMock(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         $this->orderCollection = $this->createMock(OrderCollection::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $this->orderCollectionFactory->expects($this->any()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             ->method('create') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |             ->willReturn($this->orderCollection); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $this->publisher = $this->createMock(PublisherInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $this->exportOmittedOrders = new ExportOmittedOrders( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             $this->configHelper, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             $this->orderCollectionFactory, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             $this->publisher | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |     public function testExecuteDisabled() | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |         $this->configHelper->expects($this->once()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |             ->method('isEnabled') | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |             ->willReturn(false); | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |         $this->orderCollection->expects($this->never()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |             ->method('addExcludeGuestFilter'); | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |         $this->exportOmittedOrders->run(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     public function testExecuteOrderExportDisabled() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $this->configHelper->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             ->method('isEnabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |             ->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         $this->configHelper->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |             ->method('isOrderExportEnabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |             ->willReturn(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         $this->orderCollection->expects($this->never()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |             ->method('addExcludeGuestFilter'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         $this->exportOmittedOrders->run(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     public function testRun() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         $orderIds = [123, 456]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         $this->configHelper->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             ->method('isEnabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             ->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $this->configHelper->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             ->method('isOrderExportEnabled') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             ->willReturn(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         $this->orderCollection->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             ->method('addExcludeGuestFilter') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             ->willReturnSelf(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         $this->orderCollection->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |             ->method('addOmittedFilter') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             ->willReturnSelf(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         $this->orderCollection->expects($this->once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             ->method('getAllIds') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             ->willReturn($orderIds); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         $this->publisher->expects($this->exactly(2)) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             ->method('publish'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         $this->publisher->expects($this->at(0)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |             ->method('publish') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |                 Topics::SALES_ORDER_EXPORT, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |                 json_encode(['magento_order_id' => $orderIds[0]]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         $this->publisher->expects($this->at(1)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             ->method('publish') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |                 Topics::SALES_ORDER_EXPORT, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |                 json_encode(['magento_order_id' => $orderIds[1]]) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |         $this->exportOmittedOrders->run(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 139 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 140 |  |  |  | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths