Example #1
0
 public function testAroundRead()
 {
     $this->requestGenerator->expects($this->once())->method('generate')->will($this->returnValue(['test' => 'a']));
     $result = $this->object->aroundRead($this->getMockBuilder('Magento\\Framework\\Config\\ReaderInterface')->disableOriginalConstructor()->getMock(), function () {
         return ['test' => 'b', 'd' => 'e'];
     });
     $this->assertEquals(['test' => ['b', 'a'], 'd' => 'e'], $result);
 }
 /**
  * @param array $countResult
  * @param string $code
  * @param string $type
  * @param bool $visibleInAdvanced
  * @dataProvider attributesProvider
  */
 public function testGenerate($countResult, $code, $type, $visibleInAdvanced = true)
 {
     $collection = $this->getMockBuilder('Magento\\Catalog\\Model\\Resource\\Product\\Attribute\\Collection')->disableOriginalConstructor()->getMock();
     $collection->expects($this->any())->method('getIterator')->willReturn(new \ArrayIterator([$this->createAttributeMock($code, $type, $visibleInAdvanced)]));
     $collection->expects($this->any())->method('addFieldToFilter')->with(['is_searchable', 'is_visible_in_advanced_search', 'is_filterable'], [1, 1, [1, 2]])->will($this->returnSelf());
     $this->productAttributeCollectionFactory->expects($this->any())->method('create')->willReturn($collection);
     $result = $this->object->generate();
     $this->assertEquals($countResult[0], $this->countVal($result['quick_search_container']['queries']));
     $this->assertEquals($countResult[1], $this->countVal($result['advanced_search_container']['queries']));
     $this->assertEquals($countResult[2], $this->countVal($result['advanced_search_container']['filters']));
 }
 public function testGenerate()
 {
     $requests = $this->model->generate();
     //Quick Search
     $this->assertArrayHasKey('quick_search_container', $requests);
     $quickSearch = $requests['quick_search_container'];
     $message = 'Unexpected attribute';
     $this->assertArrayHasKey('test_quick_search_bucket', $quickSearch['aggregations'], $message);
     $this->assertArrayNotHasKey('test_catalog_view_bucket', $quickSearch['aggregations'], $message);
     //Catalog View
     $this->assertArrayHasKey('catalog_view_container', $requests);
     $catalogView = $requests['catalog_view_container'];
     $this->assertArrayNotHasKey('test_quick_search_bucket', $catalogView['aggregations'], $message);
     $this->assertArrayHasKey('test_catalog_view_bucket', $catalogView['aggregations'], $message);
 }
 public function generate()
 {
     if (!$this->helper->isActiveEngine()) {
         return parent::generate();
     }
     $requests['quick_search_container'] = $this->generateQuickSearchRequest();
     // TODO: advanced search
     return $requests;
 }
 /**
  * Merge reader's value with generated
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @param \Magento\Framework\Config\ReaderInterface $subject
  * @param \Closure $proceed
  * @param string $scope
  * @return array
  */
 public function aroundRead(\Magento\Framework\Config\ReaderInterface $subject, \Closure $proceed, $scope = null)
 {
     $result = $proceed($scope);
     $result = array_merge_recursive($result, $this->requestGenerator->generate());
     return $result;
 }