| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | namespace TddWizard\Fixtures\Sales; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Magento\Sales\Api\Data\InvoiceInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Magento\Sales\Api\Data\InvoiceItemCreationInterfaceFactory; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Magento\Sales\Api\InvoiceOrderInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Magento\Sales\Api\InvoiceRepositoryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Magento\Sales\Model\Order; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Magento\TestFramework\Helper\Bootstrap; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * Builder to be used by fixtures | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | class InvoiceBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      * @var InvoiceItemCreationInterfaceFactory | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     private $itemFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * @var InvoiceOrderInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     private $invoiceOrder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * @var InvoiceRepositoryInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     private $invoiceRepository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @var Order | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     private $order; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |      * @var int[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     private $orderItems; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     final public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 10 |  |         InvoiceItemCreationInterfaceFactory $itemFactory, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         InvoiceOrderInterface $invoiceOrder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         InvoiceRepositoryInterface $invoiceRepository, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         Order $order | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $this->itemFactory = $itemFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 10 |  |         $this->invoiceOrder = $invoiceOrder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 10 |  |         $this->invoiceRepository = $invoiceRepository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 10 |  |         $this->order = $order; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 10 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $this->orderItems = []; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 10 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 10 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     public static function forOrder( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 10 |  |         Order $order | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     ): InvoiceBuilder { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $objectManager = Bootstrap::getObjectManager(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 | 10 |  |         return new static( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 10 |  |             $objectManager->create(InvoiceItemCreationInterfaceFactory::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             $objectManager->create(InvoiceOrderInterface::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             $objectManager->create(InvoiceRepositoryInterface::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 | 10 |  |             $order | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 | 10 |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 | 10 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 | 10 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     public function withItem(int $orderItemId, int $qty): InvoiceBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         $builder = clone $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 | 1 |  |         $builder->orderItems[$orderItemId] = $qty; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 | 1 |  |         return $builder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     public function build(): InvoiceInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         $invoiceItems = $this->buildInvoiceItems(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 10 |  |         $invoiceId = $this->invoiceOrder->execute($this->order->getEntityId(), false, $invoiceItems); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 | 10 |  |         return $this->invoiceRepository->get($invoiceId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 | 10 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 | 1 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 1 |  |      * @return \Magento\Sales\Api\Data\InvoiceItemCreationInterface[] | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 90 | 1 |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 91 | 1 |  |     private function buildInvoiceItems(): array | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |         $invoiceItems = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 94 | 10 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |         foreach ($this->orderItems as $orderItemId => $qty) { | 
            
                                                                        
                            
            
                                    
            
            
                | 96 | 10 |  |             $invoiceItem = $this->itemFactory->create(); | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |             $invoiceItem->setOrderItemId($orderItemId); | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |             $invoiceItem->setQty($qty); | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |             $invoiceItems[] = $invoiceItem; | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |         return $invoiceItems; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 103 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 104 |  |  |  | 
            
                        
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