Skip to content

Commit 5d537a3

Browse files
MAGETWO-86883: The function "isUsingStaticUrlsAllowed" (configuration setting "cms/wysiwyg/use_static_urls_in_catalog") doesn't have any effect with the WYSIWYG editor image insertion #1215
2 parents 83a9b9c + 2a80282 commit 5d537a3

File tree

2 files changed

+66
-1
lines changed
  • app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images
  • dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images

2 files changed

+66
-1
lines changed

app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/OnInsert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(
3535
public function execute()
3636
{
3737
$helper = $this->_objectManager->get(\Magento\Cms\Helper\Wysiwyg\Images::class);
38-
$storeId = $this->getRequest()->getParam('store');
38+
$storeId = (int)$this->getRequest()->getParam('store');
3939

4040
$filename = $this->getRequest()->getParam('filename');
4141
$filename = $helper->idDecode($filename);
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Cms\Controller\Adminhtml\Wysiwyg\Images;
8+
9+
use Magento\Cms\Helper\Wysiwyg\Images;
10+
use Magento\Framework\Data\Form\FormKey;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
use Magento\TestFramework\TestCase\AbstractBackendController;
13+
14+
/**
15+
* Provide tests for OnInsert controller.
16+
* @magentoAppArea adminhtml
17+
*/
18+
class OnInsertTest extends AbstractBackendController
19+
{
20+
/**
21+
* Test OnIsert with turned on static urls in catalog.
22+
*
23+
* @magentoConfigFixture admin_store cms/wysiwyg/use_static_urls_in_catalog 1
24+
* @return void
25+
*/
26+
public function testExecuteWhithStaticUrls()
27+
{
28+
$this->prepareRequest();
29+
$this->dispatch('backend/cms/wysiwyg_images/onInsert');
30+
$this->assertRegExp('/pub\/media\/wysiwyg\/testFilename/', $this->getResponse()->getBody());
31+
}
32+
33+
/**
34+
* Test OnIsert with turned off static urls in catalog.
35+
*
36+
* @magentoConfigFixture admin_store cms/wysiwyg/use_static_urls_in_catalog 0
37+
* @return void
38+
*/
39+
public function testExecuteWhithoutStaticUrls()
40+
{
41+
$this->prepareRequest();
42+
$this->dispatch('backend/cms/wysiwyg_images/onInsert');
43+
$this->assertRegExp('/cms\/wysiwyg\/directive\/___directive/', $this->getResponse()->getBody());
44+
}
45+
46+
/**
47+
* Set necessary post data into request.
48+
*
49+
* @return void
50+
*/
51+
private function prepareRequest()
52+
{
53+
$this->getRequest()->setParams(
54+
[
55+
'key' => 'testKey',
56+
'isAjax' => 'true',
57+
'filename' => Bootstrap::getObjectManager()->get(Images::class)->idEncode('testFilename'),
58+
'node' => 'root',
59+
'store' => '',
60+
'as_is' => '0',
61+
'form_key' => Bootstrap::getObjectManager()->get(FormKey::class)->getFormKey(),
62+
]
63+
);
64+
}
65+
}

0 commit comments

Comments
 (0)