Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SynonymReaderTest.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Search\Model;
7 
12 class SynonymReaderTest extends \PHPUnit\Framework\TestCase
13 {
17  private $model;
18 
19  protected function setUp()
20  {
22  $this->model = $objectManager->get(\Magento\Search\Model\SynonymReader::class);
23  }
24 
28  public static function loadByPhraseDataProvider()
29  {
30  return [
31  [
32  'ELIZABETH', []
33  ],
34  [
35  'ENGLISH', [['synonyms' => 'british,english', 'store_id' => 1, 'website_id' => 0]]
36  ],
37  [
38  'English', [['synonyms' => 'british,english', 'store_id' => 1, 'website_id' => 0]]
39  ],
40  [
41  'QUEEN', [['synonyms' => 'queen,monarch', 'store_id' => 1, 'website_id' => 0]]
42  ],
43  [
44  'Monarch', [['synonyms' => 'queen,monarch', 'store_id' => 1, 'website_id' => 0]]
45  ],
46  [
47  'MONARCH English', [
48  ['synonyms' => 'queen,monarch', 'store_id' => 1, 'website_id' => 0],
49  ['synonyms' => 'british,english', 'store_id' => 1, 'website_id' => 0]
50  ]
51  ]
52  ];
53  }
54 
60  public function testLoadByPhrase($phrase, $expectedResult)
61  {
62  $data = $this->model->loadByPhrase($phrase)->getData();
63 
64  $i = 0;
65  foreach ($expectedResult as $r) {
66  $this->assertEquals($r['synonyms'], $data[$i]['synonyms']);
67  $this->assertEquals($r['store_id'], $data[$i]['store_id']);
68  $this->assertEquals($r['website_id'], $data[$i]['website_id']);
69  ++$i;
70  }
71  }
72 }
$objectManager
Definition: bootstrap.php:17
testLoadByPhrase($phrase, $expectedResult)
$i
Definition: gallery.phtml:31