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

Public Member Functions

 testRenderEscaping ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $block
 

Detailed Description

@magentoAppArea frontend

Definition at line 16 of file SuggestionsTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 21 of file SuggestionsTest.php.

22  {
23  $suggestedQueries = $this->createMock(SuggestedQueriesInterface::CLASS);
24  $suggestedQueries->expects($this->any())->method('getItems')->willReturn([
25  new QueryResult('test item', 1),
26  new QueryResult("<script>alert('Test');</script>", 1)
27  ]);
28 
29  $this->block = Bootstrap::getObjectManager()->create(\Magento\AdvancedSearch\Block\Suggestions::class, [
30  'searchDataProvider' => $suggestedQueries,
31  'title' => 'title',
32  ]);
33  }

◆ testRenderEscaping()

testRenderEscaping ( )

Definition at line 35 of file SuggestionsTest.php.

36  {
37  $html = $this->block->toHtml();
38 
39  $this->assertContains('test+item', $html);
40  $this->assertContains('test item', $html);
41 
42  $this->assertNotContains('<script>', $html);
43  $this->assertContains('%3Cscript%3Ealert%28%27Test%27%29%3B%3C%2Fscript%3E', $html);
44  $this->assertContains("&lt;script&gt;alert(&#039;Test&#039;);&lt;/script&gt;", $html);
45  }

Field Documentation

◆ $block

$block
protected

Definition at line 19 of file SuggestionsTest.php.


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