Exemple #1
0
    /**
     * @expectedException \Magento\Framework\Search\Request\EmptyRequestDataException
     * @expectedExceptionMessage Request query and filter is not set
     */
    public function testCleanEmptyQueryAndFilter()
    {
        $this->status->expects($this->once())
            ->method('isEnabled')
            ->will($this->returnValue(true));
        $requestData = [
            'query' => 'bool_query',
            'queries' => [
                'bool_query' => [
                    'queryReference' => [
                        ['ref' => 'bool_query_rm'],
                        ['ref' => 'filtered_query_to_filter2'],
                    ],
                    'type' => 'boolQuery',
                ],
                'bool_query_rm' => [
                    'queryReference' => [
                        ['ref' => 'match_query_rm'],
                        ['ref' => 'filtered_query_to_query'],
                        ['ref' => 'filtered_query_to_filter'],
                    ],
                    'type' => 'boolQuery',
                ],
                'match_query_rm' => ['value' => '$some$', 'type' => 'matchQuery'],
                'match_query_rm2' => ['value' => '$some2$', 'type' => 'matchQuery'],
                'filtered_query_to_query' => [
                    'queryReference' => [['ref' => 'match_query_rm2']],
                    'type' => 'filteredQuery',
                ],
                'filtered_query_to_filter' => [
                    'filterReference' => [['ref' => 'bool_filter']],
                    'type' => 'filteredQuery',
                ],
                'filtered_query_to_filter2' => [
                    'filterReference' => [['ref' => 'bool_filter2']],
                    'type' => 'filteredQuery',
                ],
            ],
            'filters' => [
                'bool_filter' => [
                    'filterReference' => [['ref' => 'term_filter'], ['ref' => 'range_filter']],
                    'type' => 'boolFilter',
                ],
                'term_filter' => ['value' => '$val$', 'type' => 'termFilter'],
                'range_filter' => ['from' => '$from$', 'to' => '$to$', 'type' => 'rangeFilter'],
                'bool_filter2' => [
                    'filterReference' => [['ref' => 'term_filter2']],
                    'type' => 'boolFilter',
                ],
                'term_filter2' => ['value' => '$val$', 'type' => 'termFilter'],
            ],
        ];

        $this->cleaner->clean($requestData);
    }
Exemple #2
0
 /**
  * Create request object
  *
  * @return RequestInterface
  */
 public function create()
 {
     if (!isset($this->data['requestName'])) {
         throw new \InvalidArgumentException("Request name not defined.");
     }
     $requestName = $this->data['requestName'];
     /** @var array $data */
     $data = $this->config->get($requestName);
     if ($data === null) {
         throw new \InvalidArgumentException("Request name '{$requestName}' doesn't exist.");
     }
     $data = $this->binder->bind($data, $this->data);
     $data = $this->cleaner->clean($data);
     $this->clear();
     return $this->convert($data);
 }
 /**
  * @expectedException \Exception
  * @expectedExceptionMessage Query test does not exist
  */
 public function testCleanQueryNotExists()
 {
     $requestData = ['query' => 'test', 'queries' => [], 'filters' => []];
     $this->cleaner->clean($requestData);
 }