47 $this->contextMock = $this->getMockBuilder(\
Magento\Framework\View\Element\Template\Context::class)
48 ->disableOriginalConstructor()
50 $this->requestMock = $this->createPartialMock(\
Magento\Framework\
App\RequestInterface::class, [
65 $this->layoutMock = $this->getMockBuilder(\
Magento\Framework\View\LayoutInterface::class)
66 ->disableOriginalConstructor()
68 $this->layoutUpdateMock = $this->getMockBuilder(\
Magento\Framework\View\Layout\ProcessorInterface::class)
69 ->disableOriginalConstructor()
71 $this->urlBuilderMock = $this->getMockBuilder(\
Magento\Framework\UrlInterface::class)
72 ->disableOriginalConstructor()
74 $this->contextMock->expects($this->any())
75 ->method(
'getRequest')
76 ->willReturn($this->requestMock);
77 $this->contextMock->expects($this->any())
79 ->willReturn($this->layoutMock);
80 $this->contextMock->expects($this->any())
81 ->method(
'getUrlBuilder')
82 ->willReturn($this->urlBuilderMock);
83 $this->layoutMock->expects($this->any())
85 ->willReturn($this->layoutUpdateMock);
86 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
88 \
Magento\PageCache\Block\Javascript::class,
90 'context' => $this->contextMock
109 $this->requestMock->expects($this->once())
111 ->willReturn($isSecure);
112 $this->requestMock->expects($this->once())
113 ->method(
'getRouteName')
114 ->will($this->returnValue(
'route'));
115 $this->requestMock->expects($this->once())
116 ->method(
'getControllerName')
117 ->will($this->returnValue(
'controller'));
118 $this->requestMock->expects($this->once())
119 ->method(
'getActionName')
120 ->will($this->returnValue(
'action'));
121 $this->requestMock->expects($this->once())
122 ->method(
'getRequestUri')
123 ->will($this->returnValue(
'uri'));
124 $this->urlBuilderMock->expects($this->once())
127 $this->layoutUpdateMock->expects($this->once())
128 ->method(
'getHandles')
129 ->willReturn($handles);
130 $this->assertRegExp($expectedResult, $this->blockJavascript->getScriptOptions());
141 'url' =>
'http://some-name.com/page_cache/block/render',
142 'expectedResult' =>
'~http:\\\\/\\\\/some-name\\.com.+\\["some","handles","here"\\]~' 146 'url' =>
'https://some-name.com/page_cache/block/render',
147 'expectedResult' =>
'~https:\\\\/\\\\/some-name\\.com.+\\["some","handles","here"\\]~' 169 $this->requestMock->expects($this->once())
173 $this->requestMock->expects($this->once())
174 ->method(
'getRouteName')
175 ->will($this->returnValue($route));
177 $this->requestMock->expects($this->once())
178 ->method(
'getControllerName')
181 $this->requestMock->expects($this->once())
182 ->method(
'getActionName')
183 ->will($this->returnValue($action));
185 $this->requestMock->expects($this->once())
186 ->method(
'getRequestUri')
187 ->will($this->returnValue($uri));
189 $this->urlBuilderMock->expects($this->once())
193 $this->layoutUpdateMock->expects($this->once())
194 ->method(
'getHandles')
195 ->willReturn($handles);
196 $this->assertRegExp($expectedResult, $this->blockJavascript->getScriptOptions());
207 'url' =>
'http://some-name.com/page_cache/block/render',
209 'controller' =>
'controller',
210 'action' =>
'action',
212 'expectedResult' =>
'~"originalRequest":{"route":"route","controller":"controller","action":"action","uri":"uri"}~'
testGetScriptOptions($isSecure, $url, $expectedResult)
testGetScriptOptionsPrivateContent($url, $route, $controller, $action, $uri, $expectedResult)
getScriptOptionsDataProvider()
getScriptOptionsPrivateContentDataProvider()