Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
AdapterTest Class Reference
Inheritance diagram for AdapterTest:
AdapterTest

Public Member Functions

 testMatchQuery ()
 
 testMatchOrderedQuery ()
 
 testAggregationsQuery ()
 
 testMatchQueryFilters ()
 
 testRangeFilterWithAllFields ()
 
 testRangeFilterWithoutFromField ()
 
 testRangeFilterWithoutToField ()
 
 testTermFilter ()
 
 testTermFilterArray ()
 
 testWildcardFilter ()
 
 testSearchLimit ()
 
 testBoolFilter ()
 
 testBoolFilterWithNestedNegativeBoolFilter ()
 
 testBoolFilterWithNestedRangeInNegativeBoolFilter ()
 
 testSimpleAdvancedSearch ( $nameQuery, $descriptionQuery, $rangeFilter, $expectedRecordsCount)
 
 elasticSearchAdvancedSearchDataProvider ()
 
 testCustomFilterableAttribute ()
 
 testFilterByAttributeValues ($requestName, $additionalData)
 
 testAdvancedSearchDateField ($rangeFilter, $expectedRecordsCount)
 
 testAdvancedSearchCompositeProductWithOutOfStockOption ()
 
 testAdvancedSearchCompositeProductWithDisabledChild ()
 
 testSearchQueryBoost ()
 
- Public Member Functions inherited from AdapterTest
 testMatchQuery ()
 
 testMatchOrderedQuery ()
 
 testAggregationsQuery ()
 
 testMatchQueryFilters ()
 
 testRangeFilterWithAllFields ()
 
 testRangeFilterWithoutFromField ()
 
 testRangeFilterWithoutToField ()
 
 testTermFilter ()
 
 testTermFilterArray ()
 
 testWildcardFilter ()
 
 testSearchLimit ()
 
 testBoolFilter ()
 
 testBoolFilterWithNestedNegativeBoolFilter ()
 
 testBoolFilterWithNestedRangeInNegativeBoolFilter ()
 
 testSimpleAdvancedSearch ( $nameQuery, $descriptionQuery, $rangeFilter, $expectedRecordsCount)
 
 advancedSearchDataProvider ()
 
 filterByAttributeValuesDataProvider ()
 
 testAdvancedSearchDateField ($rangeFilter, $expectedRecordsCount)
 
 dateDataProvider ()
 

Protected Member Functions

 getRequestConfigPath ()
 
 createAdapter ()
 
- Protected Member Functions inherited from AdapterTest
 getRequestConfigPath ()
 
 assertPreConditions ()
 
 createAdapter ()
 

Protected Attributes

 $searchEngine = Config::ENGINE_NAME
 
- Protected Attributes inherited from AdapterTest
 $objectManager
 
 $searchEngine = EngineResolver::CATALOG_SEARCH_MYSQL_ENGINE
 

Detailed Description

Class AdapterTest

@magentoDbIsolation disabled @magentoDataFixture Magento/Framework/Search/_files/products.php

Important: Please make sure that each integration test file works with unique elastic search index. In order to achieve this, use @ magentoConfigFixture to pass unique value for 'elasticsearch_index_prefix' for every test method. E.g. '@ magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest'

In ElasticSearch, a reindex is required if the test includes a new data fixture with new items to search, see testAdvancedSearchDateField().

Definition at line 24 of file AdapterTest.php.

Member Function Documentation

◆ createAdapter()

createAdapter ( )
protected
Returns
\Magento\Framework\Search\AdapterInterface

Definition at line 44 of file AdapterTest.php.

45  {
46  return $this->objectManager->create(\Magento\Elasticsearch\SearchAdapter\Adapter::class);
47  }

◆ elasticSearchAdvancedSearchDataProvider()

elasticSearchAdvancedSearchDataProvider ( )

Elastic Search specific data provider for advanced search test.

The expected array is for Elastic Search is different that the one for MySQL because sometimes more matches are returned. For instance, 3rd index below will return 3 matches instead of 1 (which is what MySQL returns).

Returns
array

Definition at line 246 of file AdapterTest.php.

247  {
248  return [
249  ['white', 'shorts', ['from' => '16', 'to' => '18'], 0],
250  ['white', 'shorts',['from' => '12', 'to' => '18'], 1],
251  ['black', 'tshirts', ['from' => '12', 'to' => '20'], 0],
252  ['shorts', 'green', ['from' => '12', 'to' => '22'], 3],
253  //Search with empty fields/values
254  ['white', ' ', ['from' => '12', 'to' => '22'], 1],
255  [' ', 'green', ['from' => '12', 'to' => '22'], 2]
256  ];
257  }

◆ getRequestConfigPath()

getRequestConfigPath ( )
protected

Get request config path

Returns
string

Definition at line 36 of file AdapterTest.php.

37  {
38  return __DIR__ . '/../_files/requests.xml';
39  }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60

◆ testAdvancedSearchCompositeProductWithDisabledChild()

testAdvancedSearchCompositeProductWithDisabledChild ( )

@magentoDataFixture Magento/Framework/Search/_files/product_configurable_with_disabled_child.php @magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

@magentoDataFixture Magento/Framework/Search/_files/product_configurable_with_disabled_child.php @magentoConfigFixture default/catalog/search/engine mysql

Definition at line 326 of file AdapterTest.php.

327  {
328  // Reindex Elastic Search since date_attribute data fixture added new fields to be indexed
329  $this->reindexAll();
330  parent::testAdvancedSearchCompositeProductWithDisabledChild();
331  }

◆ testAdvancedSearchCompositeProductWithOutOfStockOption()

testAdvancedSearchCompositeProductWithOutOfStockOption ( )

@magentoDataFixture Magento/Framework/Search/_files/product_configurable.php @magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

@magentoDataFixture Magento/Framework/Search/_files/product_configurable.php @magentoConfigFixture default/catalog/search/engine mysql

Definition at line 315 of file AdapterTest.php.

316  {
317  parent::testAdvancedSearchCompositeProductWithOutOfStockOption();
318  }

◆ testAdvancedSearchDateField()

testAdvancedSearchDateField (   $rangeFilter,
  $expectedRecordsCount 
)

Advanced search request using date product attribute

Parameters
$rangeFilter
$expectedRecordsCount@magentoDataFixture Magento/Framework/Search/_files/date_attribute.php @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest @magentoAppIsolation enabled @dataProvider dateDataProvider

Definition at line 302 of file AdapterTest.php.

303  {
304  // Reindex Elastic Search since date_attribute data fixture added new fields to be indexed
305  $this->reindexAll();
306  parent::testAdvancedSearchDateField($rangeFilter, $expectedRecordsCount);
307  }

◆ testAggregationsQuery()

testAggregationsQuery ( )

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 76 of file AdapterTest.php.

77  {
78  $this->markTestSkipped('Range query is not supported. Test is skipped intentionally.');
79  }

◆ testBoolFilter()

testBoolFilter ( )

Bool filter test

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 182 of file AdapterTest.php.

183  {
184  parent::testBoolFilter();
185  }

◆ testBoolFilterWithNestedNegativeBoolFilter()

testBoolFilterWithNestedNegativeBoolFilter ( )

Test bool filter with nested negative bool filter

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 194 of file AdapterTest.php.

195  {
196  parent::testBoolFilterWithNestedNegativeBoolFilter();
197  }

◆ testBoolFilterWithNestedRangeInNegativeBoolFilter()

testBoolFilterWithNestedRangeInNegativeBoolFilter ( )

Test range inside nested negative bool filter

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 206 of file AdapterTest.php.

207  {
208  parent::testBoolFilterWithNestedRangeInNegativeBoolFilter();
209  }

◆ testCustomFilterableAttribute()

testCustomFilterableAttribute ( )

@magentoAppIsolation enabled @magentoDataFixture Magento/Framework/Search/_files/filterable_attribute.php @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

@magentoDataFixture Magento/Framework/Search/_files/filterable_attribute.php @magentoConfigFixture default/catalog/search/engine mysql

Definition at line 265 of file AdapterTest.php.

266  {
267  // Reindex Elastic Search since filterable_attribute data fixture added new fields to be indexed
268  $this->reindexAll();
269  parent::testCustomFilterableAttribute();
270  }

◆ testFilterByAttributeValues()

testFilterByAttributeValues (   $requestName,
  $additionalData 
)

Test filtering by two attributes.

@magentoAppIsolation enabled @magentoDataFixture Magento/Framework/Search/_files/filterable_attributes.php @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest @dataProvider filterByAttributeValuesDataProvider

Parameters
string$requestName
array$additionalData
Returns
void

Test filtering by two attributes.

@magentoDataFixture Magento/Framework/Search/_files/filterable_attributes.php @magentoConfigFixture default/catalog/search/engine mysql @dataProvider filterByAttributeValuesDataProvider

Parameters
string$requestName
array$additionalData
Returns
void

Definition at line 284 of file AdapterTest.php.

285  {
286  // Reindex Elastic Search since filterable_attribute data fixture added new fields to be indexed
287  $this->reindexAll();
288  parent::testFilterByAttributeValues($requestName, $additionalData);
289  }

◆ testMatchOrderedQuery()

testMatchOrderedQuery ( )

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 64 of file AdapterTest.php.

65  {
66  $this->markTestSkipped(
67  'Elasticsearch not expected to order results by default. Test is skipped intentionally.'
68  );
69  }

◆ testMatchQuery()

testMatchQuery ( )

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 54 of file AdapterTest.php.

55  {
56  parent::testMatchQuery();
57  }

◆ testMatchQueryFilters()

testMatchQueryFilters ( )

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 86 of file AdapterTest.php.

87  {
88  parent::testMatchQueryFilters();
89  }

◆ testRangeFilterWithAllFields()

testRangeFilterWithAllFields ( )

Range filter test with all fields filled

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 98 of file AdapterTest.php.

99  {
100  parent::testRangeFilterWithAllFields();
101  }

◆ testRangeFilterWithoutFromField()

testRangeFilterWithoutFromField ( )

Range filter test with all fields filled

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 110 of file AdapterTest.php.

111  {
112  parent::testRangeFilterWithoutFromField();
113  }

◆ testRangeFilterWithoutToField()

testRangeFilterWithoutToField ( )

Range filter test with all fields filled

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 122 of file AdapterTest.php.

123  {
124  parent::testRangeFilterWithoutToField();
125  }

◆ testSearchLimit()

testSearchLimit ( )

Request limits test

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 170 of file AdapterTest.php.

171  {
172  parent::testSearchLimit();
173  }

◆ testSearchQueryBoost()

testSearchQueryBoost ( )

@magentoDataFixture Magento/Framework/Search/_files/search_weight_products.php @magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Test for search weight customization to ensure that search weight works correctly, and affects search results.

@magentoDataFixture Magento/Framework/Search/_files/search_weight_products.php @magentoConfigFixture default/catalog/search/engine mysql

Definition at line 339 of file AdapterTest.php.

340  {
341  // Reindex Elastic Search since date_attribute data fixture added new fields to be indexed
342  $this->reindexAll();
343  parent::testSearchQueryBoost();
344  }

◆ testSimpleAdvancedSearch()

testSimpleAdvancedSearch (   $nameQuery,
  $descriptionQuery,
  $rangeFilter,
  $expectedRecordsCount 
)

Sample Advanced search request test

@dataProvider elasticSearchAdvancedSearchDataProvider @magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Parameters
string$nameQuery
string$descriptionQuery
array$rangeFilter
int$expectedRecordsCount

Definition at line 223 of file AdapterTest.php.

228  {
229  parent::testSimpleAdvancedSearch(
230  $nameQuery,
231  $descriptionQuery,
232  $rangeFilter,
233  $expectedRecordsCount
234  );
235  }

◆ testTermFilter()

testTermFilter ( )

Term filter test

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 134 of file AdapterTest.php.

135  {
136  parent::testTermFilter();
137  }

◆ testTermFilterArray()

testTermFilterArray ( )

Term filter test

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 146 of file AdapterTest.php.

147  {
148  parent::testTermFilterArray();
149  }

◆ testWildcardFilter()

testWildcardFilter ( )

Term filter test

@magentoAppIsolation enabled @magentoConfigFixture default/catalog/search/engine elasticsearch @magentoConfigFixture current_store catalog/search/elasticsearch_index_prefix adaptertest

Definition at line 158 of file AdapterTest.php.

159  {
160  parent::testWildcardFilter();
161  }

Field Documentation

◆ $searchEngine

$searchEngine = Config::ENGINE_NAME
protected

Definition at line 29 of file AdapterTest.php.


The documentation for this class was generated from the following file: