| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace spec\Gewebe\SyliusProductDepositPlugin\OrderProcessing; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\Common\Collections\ArrayCollection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Gewebe\SyliusProductDepositPlugin\Entity\ChannelDepositInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Gewebe\SyliusProductDepositPlugin\Entity\ProductVariantInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Gewebe\SyliusProductDepositPlugin\OrderProcessing\OrderDepositProcessor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use PhpSpec\ObjectBehavior; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Sylius\Component\Addressing\Matcher\ZoneMatcherInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Sylius\Component\Addressing\Model\ZoneInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Sylius\Component\Core\Model\AddressInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Sylius\Component\Core\Model\ChannelInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Sylius\Component\Core\Model\OrderInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Sylius\Component\Core\Model\OrderItemInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Sylius\Component\Core\Provider\ZoneProviderInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Sylius\Component\Core\Taxation\Applicator\OrderTaxesApplicatorInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Sylius\Component\Order\Processor\OrderProcessorInterface; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  | final class OrderDepositProcessorSpec extends ObjectBehavior | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     function let( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         ZoneProviderInterface $defaultTaxZoneProvider, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         ZoneMatcherInterface $zoneMatcher, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         OrderTaxesApplicatorInterface $orderTaxesApplicator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     ): void { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 29 |  |  |         $this->beConstructedWith($defaultTaxZoneProvider, $zoneMatcher, $orderTaxesApplicator); | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |     function it_is_initializable(): void | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         $this->shouldHaveType(OrderDepositProcessor::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     function it_implements_order_processor_interface(): void | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |         $this->shouldImplement(OrderProcessorInterface::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     function it_process_order_deposit( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         AddressInterface $address, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         ChannelInterface $channel, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         ChannelDepositInterface $channelDeposit, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         OrderInterface $order, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         OrderItemInterface $orderItem, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         OrderTaxesApplicatorInterface $orderTaxesApplicator, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         ProductVariantInterface $productVariant, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         ZoneProviderInterface $defaultTaxZoneProvider, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         ZoneMatcherInterface $zoneMatcher, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         ZoneInterface $zone | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     ): void { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $channelDeposit->getPrice()->willReturn(50); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $productVariant->getChannelDepositForChannel($channel)->willReturn($channelDeposit); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $orderItem->getVariant()->willReturn($productVariant); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $orderItem->getUnitPrice()->willReturn(400); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $orderItem->setUnitPrice(450)->shouldBeCalled(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $order->getChannel()->willReturn($channel); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $order->getItems()->willReturn(new ArrayCollection([$orderItem->getWrappedObject()])); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $order->getShippingAddress()->willReturn($address); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $defaultTaxZoneProvider->getZone($order)->willReturn($zone); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         $this->beConstructedWith($defaultTaxZoneProvider, $zoneMatcher, $orderTaxesApplicator); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 69 |  |  |         $this->process($order); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                                                                
            
                                    
            
            
                | 70 |  |  |     } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 71 |  |  | } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 72 |  |  |  | 
            
                        
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.