Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FilterEmulateTest.php
Go to the documentation of this file.
1 <?php
7 
8 use \Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
9 
10 class FilterEmulateTest extends \PHPUnit\Framework\TestCase
11 {
16 
20  protected $filterEmulate;
21 
25  protected $appStateMock;
26 
30  protected function setUp()
31  {
32  $this->objectManagerHelper = new ObjectManagerHelper($this);
33  $this->appStateMock = $this->createMock(\Magento\Framework\App\State::class);
34 
35  $this->filterEmulate = $this->objectManagerHelper->getObject(
36  \Magento\Widget\Model\Template\FilterEmulate::class,
37  ['appState' => $this->appStateMock]
38  );
39  }
40 
44  public function testWidgetDirective()
45  {
46  $result = 'some text';
47  $construction = [
48  '{{widget type="Widget\\Link" anchor_text="Test" template="block.phtml" id_path="p/1"}}',
49  'widget',
50  ' type="" anchor_text="Test" template="block.phtml" id_path="p/1"'
51  ];
52 
53  $this->appStateMock->expects($this->once())
54  ->method('emulateAreaCode')
55  ->with('frontend', [$this->filterEmulate, 'generateWidget'], [$construction])
56  ->willReturn($result);
57  $this->assertSame($result, $this->filterEmulate->widgetDirective($construction));
58  }
59 }