8 use \Magento\Framework\Translate\Inline;
44 $this->scopeResolverMock =
45 $this->createMock(\
Magento\Framework\
App\ScopeResolverInterface::class);
46 $this->urlMock = $this->createMock(\
Magento\Framework\UrlInterface::class);
47 $this->layoutMock = $this->createMock(\
Magento\Framework\View\LayoutInterface::class);
65 $this->scopeResolverMock,
83 [
true,
true,
true,
true],
84 [
true,
false,
true,
false],
85 [
true,
true,
false,
false],
86 [
true,
false,
false,
false],
87 [
false,
true,
true,
false],
88 [
false,
false,
true,
false],
89 [
false,
true,
false,
false],
90 [
false,
false,
false,
false],
97 $this->scopeResolverMock,
104 $this->assertEquals($this->parserMock,
$model->getParser());
118 $this->scopeResolverMock,
128 $model->processResponseBody($body,
true);
129 $this->assertEquals($body, $expected);
139 [
'{{{aaaaaa}}{{bbbbb}}{{eeeee}}{{cccccc}}}',
'aaaaaa'],
140 [[
'test1',
'test2'], [
'test1',
'test2'],],
141 [[
'{{{aaaaaa}}',
'test3'], [
'{{{aaaaaa}}',
'test3'],],
142 [[
'{{{aaaaaa}}{{bbbbb}}',
'test4'], [
'{{{aaaaaa}}{{bbbbb}}',
'test4'],],
143 [[
'{{{aaaaaa}}{{bbbbb}}{{eeeee}}{{cccccc}}}',
'test5'], [
'aaaaaa',
'test5'],],
159 $jsonCall = is_array($body) ? 2 * (count($body) + 1) : 2;
160 $this->parserMock->expects(
161 $this->exactly($jsonCall)
165 $this->returnValueMap([
166 [$isJson, $this->returnSelf()],
167 [!$isJson, $this->returnSelf()],
170 $this->parserMock->expects(
173 'processResponseBodyString' 175 is_array($body) ? reset($body) : $body
177 $this->parserMock->expects(
182 $this->returnValue(is_array($body) ? reset($body) : $body)
186 $this->scopeResolverMock,
197 $model->processResponseBody($body, $isJson);
198 $this->assertEquals($body, $expected);
207 [
'admin',
'test',
'test'],
208 [
'not_admin',
'test1',
'test1'],
224 $jsonCall = is_array($body) ? 2 * (count($body) + 1) : 2;
225 $this->parserMock->expects(
226 $this->exactly($jsonCall)
230 $this->returnValueMap([
231 [$isJson, $this->returnSelf()],
232 [!$isJson, $this->returnSelf()],
235 $this->parserMock->expects(
238 'processResponseBodyString' 240 is_array($body) ? reset($body) : $body
242 $this->parserMock->expects(
247 $this->returnValue(is_array($body) ? reset($body) : $body)
251 $this->scopeResolverMock,
262 $model->processResponseBody($body, $isJson);
263 $this->assertEquals($body, $expected);
272 [
'admin',
'test',
'test'],
273 [
'not_admin',
'test1',
'test1'],
285 $scopeMock = $this->createMock(\
Magento\Framework\
App\Config\ScopeConfigInterface::class);
286 $this->stateMock->expects($this->any())->method(
'isEnabled')->will($this->returnValue($isEnabled));
287 $this->scopeResolverMock->expects(
294 $this->returnValue($scopeMock)
297 $this->configMock->expects(
304 $this->returnValue($isActive)
307 $this->configMock->expects(
308 $this->exactly((
int)$isActive)
312 $this->returnValue($isDevAllowed)
testProcessResponseBody($scope, $body, $expected)
testProcessResponseBodyStripInline($body, $expected)
processResponseBodyGetInlineScriptDataProvider()
processResponseBodyStripInlineDataProvider()
prepareIsAllowed($isEnabled, $isActive, $isDevAllowed, $scope=null)
processResponseBodyDataProvider()
testIsAllowed($isEnabled, $isActive, $isDevAllowed, $result)
testProcessResponseBodyGetInlineScript($scope, $body, $expected)