53 $this->contextMock = $this->createMock(\
Magento\Backend\Block\Template\Context::class);
54 $this->mediaHelper = $this->createMock(\
Magento\ProductVideo\Helper\Media::class);
55 $this->mathRandom = $this->createMock(\
Magento\Framework\Math\Random::class);
56 $this->urlBuilder = $this->createMock(\
Magento\Framework\UrlInterface::class);
57 $this->contextMock->expects($this->any())->method(
'getMathRandom')->willReturn($this->mathRandom);
58 $this->contextMock->expects($this->any())->method(
'getUrlBuilder')->willReturn($this->urlBuilder);
59 $this->registryMock = $this->createMock(\
Magento\Framework\Registry::class);
60 $this->formFactoryMock = $this->createMock(\
Magento\Framework\Data\FormFactory::class);
61 $this->jsonEncoderMock = $this->createMock(\
Magento\Framework\Json\EncoderInterface::class);
63 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
66 \
Magento\ProductVideo\Block\Adminhtml\Product\Edit\NewVideo::class,
68 'context' => $this->contextMock,
69 'mediaHelper' => $this->mediaHelper,
70 'urlBuilder' => $this->urlBuilder,
71 'jsonEncoder' => $this->jsonEncoderMock,
72 'registry' => $this->registryMock,
73 'formFactory' => $this->formFactoryMock,
80 $this->mathRandom->expects($this->any())->method(
'getUniqueHash')->with(
'id_')->willReturn(
'id_' . rand());
81 $result = $this->block->getHtmlId();
88 $this->mathRandom->expects($this->any())->method(
'getUniqueHash')->with(
'id_')->willReturn(
'id_' . $rand);
89 $saveVideoUrl =
'http://host/index.php/admin/catalog/product_gallery/upload/key/';
90 $saveRemoteVideoUrl =
'http://host/index.php/admin/product_video/product_gallery/retrieveImage/';
91 $this->urlBuilder->expects($this->exactly(2))->method(
'getUrl')->willReturnOnConsecutiveCalls(
96 'saveVideoUrl' => $saveVideoUrl,
97 'saveRemoteVideoUrl' => $saveRemoteVideoUrl,
98 'htmlId' =>
'id_' . $rand,
99 'youTubeApiKey' =>
null,
100 'videoSelector' =>
'#media_gallery_content' 102 $this->jsonEncoderMock->expects($this->once())->method(
'encode')->with(
107 $result = $this->block->getWidgetOptions();