| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file has been created by developers from BitBag. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Feel free to contact us once you face any issues or want to start | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * another great project. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * You can find more information about us on https://bitbag.shop and write us | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * an email on [email protected]. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | namespace spec\BitBag\SyliusElasticsearchPlugin\Transformer\Product; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use BitBag\SyliusElasticsearchPlugin\Transformer\Product\TransformerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use PhpSpec\ObjectBehavior; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Sylius\Component\Channel\Context\ChannelContextInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Sylius\Component\Core\Model\ChannelInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Sylius\Component\Core\Model\ChannelPricingInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Sylius\Component\Core\Model\ProductInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use Sylius\Component\Core\Model\ProductVariantInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use Sylius\Component\Currency\Model\CurrencyInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use Sylius\Component\Product\Resolver\ProductVariantResolverInterface; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  | final class ChannelPricingTransformerSpec extends ObjectBehavior | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     function let( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         ChannelContextInterface $channelContext, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         ProductVariantResolverInterface $productVariantResolver, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         MoneyFormatterInterface $moneyFormatter | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     ): void { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 33 |  |  |         $this->beConstructedWith($channelContext, $productVariantResolver, $moneyFormatter); | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |     function it_is_a_transformer(): void | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |         $this->shouldImplement(TransformerInterface::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     function it_transforms_product_channel_prices_into_formatted_price( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         ChannelContextInterface $channelContext, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         ProductVariantResolverInterface $productVariantResolver, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         MoneyFormatterInterface $moneyFormatter, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         CurrencyInterface $currency, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         ChannelInterface $channel, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         ProductVariantInterface $productVariant, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         ProductInterface $product, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         ChannelPricingInterface $channelPricing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     ): void { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $currency->getCode()->willReturn('USD'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         $channel->getBaseCurrency()->willReturn($currency); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         $channelContext->getChannel()->willReturn($channel); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $productVariantResolver->getVariant($product)->willReturn($productVariant); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $channelPricing->getPrice()->willReturn(10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $productVariant->getChannelPricingForChannel($channel)->willReturn($channelPricing); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $moneyFormatter->format(10, 'USD'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 60 |  |  |         $this->transform($product); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                                                                
            
                                    
            
            
                | 61 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 62 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 63 |  |  |  | 
            
                        
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.