| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace spec\BitBag\SyliusElasticsearchPlugin\Facet; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use BitBag\SyliusElasticsearchPlugin\Facet\FacetInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use BitBag\SyliusElasticsearchPlugin\Facet\PriceFacet; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use BitBag\SyliusElasticsearchPlugin\PropertyNameResolver\ConcatedNameResolverInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Elastica\Aggregation\Histogram; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Elastica\Query\BoolQuery; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Elastica\Query\Range; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use PhpSpec\ObjectBehavior; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Sylius\Component\Core\Context\ShopperContextInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Sylius\Component\Core\Model\Channel; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | class PriceFacetSpec extends ObjectBehavior | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     private $interval = 1000000; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |     function let( | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |         ConcatedNameResolverInterface $channelPricingNameResolver, | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |         MoneyFormatterInterface $moneyFormatter, | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |         ShopperContextInterface $shopperContext | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |     ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |         $channel = new Channel(); | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |         $channel->setCode('web_us'); | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |         $shopperContext->getChannel()->willReturn($channel); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |         $this->beConstructedWith( | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |             $channelPricingNameResolver, | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |             $moneyFormatter, | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |             $shopperContext, | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |             $this->interval | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     function it_is_initializable() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $this->shouldHaveType(PriceFacet::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     function it_implements_facet_interface() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $this->shouldHaveType(FacetInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     function it_returns_histogram_aggregation_for_price_field(ConcatedNameResolverInterface $channelPricingNameResolver) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         $channelPricingNameResolver->resolvePropertyName('web_us')->shouldBeCalled()->willReturn('price_web_us'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $expectedHistogram = new Histogram('price', 'price_web_us', $this->interval); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         $expectedHistogram->setMinimumDocumentCount(1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         $this->getAggregation()->shouldBeLike($expectedHistogram); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     function it_returns_bool_query_made_of_ranges_based_on_selected_histograms(ConcatedNameResolverInterface $channelPricingNameResolver) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $channelPricingNameResolver->resolvePropertyName('web_us')->shouldBeCalled()->willReturn('price_web_us'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $selectedHistograms = [1000000, 4000000]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $expectedQuery = new BoolQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $expectedQuery->addShould(new Range('price_web_us', ['gte' => 1000000, 'lte' => 2000000])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $expectedQuery->addShould(new Range('price_web_us', ['gte' => 4000000, 'lte' => 5000000])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $this->getQuery($selectedHistograms)->shouldBeLike($expectedQuery); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     function it_returns_money_formatted_bucket_label( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         MoneyFormatterInterface $moneyFormatter, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         ShopperContextInterface $shopperContext | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $shopperContext->getCurrencyCode()->willReturn('USD'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         $shopperContext->getLocaleCode()->willReturn('en_US'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         $moneyFormatter->format(1000000, 'USD', 'en_US')->shouldBeCalled()->willReturn('$10,000.00'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         $moneyFormatter->format(2000000, 'USD', 'en_US')->shouldBeCalled()->willReturn('$20,000.00'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         $this->getBucketLabel(['key' => 1000000, 'doc_count' => 6])->shouldBe('$10,000.00 - $20,000.00 (6)'); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 77 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 78 |  |  |  | 
            
                        
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.