Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OnInsertTest.php
Go to the documentation of this file.
1 <?php
7 
8 class OnInsertTest extends \PHPUnit\Framework\TestCase
9 {
11  protected $controller;
12 
14  protected $view;
15 
17  protected $objectManager;
18 
20  protected $storageHelper;
21 
23  protected $response;
24 
25  protected function setUp()
26  {
27  $this->objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
28  $this->view = $this->createMock(\Magento\Framework\App\ViewInterface::class);
29  $this->storageHelper = $this->createMock(\Magento\Theme\Helper\Storage::class);
30  $this->response = $this->createPartialMock(\Magento\Framework\App\Response\Http::class, ['setBody']);
31 
32  $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
33  $this->controller = $helper->getObject(
34  \Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files\OnInsert::class,
35  [
36  'objectManager' => $this->objectManager,
37  'view' => $this->view,
38  'response' => $this->response
39  ]
40  );
41  }
42 
43  public function testExecute()
44  {
45  $this->objectManager->expects($this->once())
46  ->method('get')
47  ->with(\Magento\Theme\Helper\Storage::class)
48  ->willReturn($this->storageHelper);
49  $this->storageHelper
50  ->expects($this->once())
51  ->method('getRelativeUrl')
52  ->willReturn('http://relative.url/');
53  $this->response->expects($this->once())
54  ->method('setBody')
55  ->with('http://relative.url/');
56 
57  $this->controller->execute();
58  }
59 }
$helper
Definition: iframe.phtml:13