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

Public Member Functions

 testGetSynonymsForPhrase ($phrase, $expectedResult)
 

Static Public Member Functions

static loadGetSynonymsForPhraseDataProvider ()
 

Protected Member Functions

 setUp ()
 

Detailed Description

@magentoDataFixture Magento/Search/_files/synonym_reader.php @magentoDbIsolation disabled

Definition at line 12 of file SynonymAnalyzerTest.php.

Member Function Documentation

◆ loadGetSynonymsForPhraseDataProvider()

static loadGetSynonymsForPhraseDataProvider ( )
static

Data provider for the test

Returns
array

Definition at line 30 of file SynonymAnalyzerTest.php.

31  {
32  return [
33  'WithSynonymsFromStoreViewScope' => [
34  'phrase' => 'elizabeth is the english queen',
35  'expectedResult' => [['elizabeth'],['is'],['the'],['british', 'english'],['queen', 'monarch']]
36  ],
37  'WithSynonymsFromWebsiteScope' => [
38  'phrase' => 'orange hill',
39  'expectedResult' => [['orange', 'magento'], ['hill', 'mountain', 'peak']]
40  ],
41  'WithSynonymsFromDefaultScope' => [
42  'phrase' => 'universe is enormous',
43  'expectedResult' => [['universe', 'cosmos'], ['is'], ['big', 'huge', 'large', 'enormous']]
44  ],
45  'WithCaseMismatch' => [
46  'phrase' => 'GNU\'s Not Unix',
47  'expectedResult' => [['GNU\'s'], ['Not'], ['unix', 'linux'],]
48  ],
49  'WithMultiWordPhrase' => [
50  'phrase' => 'Coastline of Great Britain stretches for 11,073 miles',
51  'expectedResult' => [
52  ['Coastline'],
53  ['of'],
54  ['Great Britain', 'United Kingdom'],
55  ['Britain'],
56  ['stretches'],
57  ['for'],
58  ['11,073'],
59  ['miles']
60  ]
61  ],
62  'PartialSynonymMatching' => [
63  'phrase' => 'Magento Engineering',
64  'expectedResult' => [
65  ['orange', 'magento'],
66  ['Engineering', 'Technical Staff']
67  ]
68  ],
69  'noSynonyms' => [
70  'phrase' => 'this sentence has no synonyms',
71  'expectedResult' => [['this'], ['sentence'], ['has'], ['no'], ['synonyms']]
72  ],
73  'multipleSpaces' => [
74  'phrase' => 'GNU\'s Not Unix',
75  'expectedResult' => [['GNU\'s'], ['Not'], ['unix', 'linux'],]
76  ],
77  'oneMoreTest' => [
78  'phrase' => 'schlicht',
79  'expectedResult' => [['schlicht', 'natürlich']]
80  ],
81  ];
82  }

◆ setUp()

setUp ( )
protected

Definition at line 19 of file SynonymAnalyzerTest.php.

20  {
22  $this->synAnalyzer = $objectManager->get(\Magento\Search\Model\SynonymAnalyzer::class);
23  }
$objectManager
Definition: bootstrap.php:17

◆ testGetSynonymsForPhrase()

testGetSynonymsForPhrase (   $phrase,
  $expectedResult 
)
Parameters
string$phrase
array$expectedResult@dataProvider loadGetSynonymsForPhraseDataProvider

Definition at line 89 of file SynonymAnalyzerTest.php.

90  {
91  $synonyms = $this->synAnalyzer->getSynonymsForPhrase($phrase);
92  $this->assertEquals($expectedResult, $synonyms);
93  }

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