Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FulltextGridSearchTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
11 
16 {
25  public function testSearchByTitle(string $query, int $expectedRows, array $expectedTitles)
26  {
27  $url = 'backend/mui/index/render/?namespace=cms_page_listing&search=' . $query;
28 
29  $this->getRequest()
30  ->getHeaders()
31  ->addHeaderLine('Accept', 'application/json');
32  $this->dispatch($url);
33  $response = $this->getResponse();
34  $data = json_decode($response->getBody(), true);
35  self::assertEquals($expectedRows, $data['totalRecords']);
36 
37  $titleList = array_column($data['items'], 'title');
38  self::assertEquals($expectedTitles, $titleList);
39  }
40 
46  public function queryDataProvider(): array
47  {
48  return [
49  [
50  'query' => 'simple',
51  'expectedRows' => 3,
52  'expectedTitles' => ['simplePage', 'simplePage01', '01simplePage']
53  ],
54  [
55  'query' => 'page01',
56  'expectedRows' => 1,
57  'expectedTitles' => ['simplePage01']
58  ],
59  [
60  'query' => '01simple',
61  'expectedRows' => 1,
62  'expectedTitles' => ['01simplePage']
63  ],
64  ];
65  }
66 }
$response
Definition: 404.php:11
testSearchByTitle(string $query, int $expectedRows, array $expectedTitles)