Skip to content

Commit c79dd63

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-70642' into 2.2-develop-pr8
2 parents 1cfa561 + 50452a1 commit c79dd63

File tree

2 files changed

+104
-0
lines changed
  • app/code/Magento/Theme/Controller/Adminhtml/Design/Config
  • dev/tests/integration/testsuite/Magento/Theme/Controller/Adminhtml/System/Design/Config

2 files changed

+104
-0
lines changed

app/code/Magento/Theme/Controller/Adminhtml/Design/Config/Save.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ protected function getRequestData()
115115
$data = array_filter($data, function ($param) {
116116
return isset($param['error']) && $param['error'] > 0 ? false : true;
117117
});
118+
119+
/**
120+
* Set null to theme id in case it's empty string,
121+
* in order to delete value from db config but not set empty string,
122+
* which may cause an error in Magento/Theme/Model/ResourceModel/Theme/Collection::getThemeByFullPath().
123+
*/
124+
if (isset($data['theme_theme_id']) && $data['theme_theme_id'] === '') {
125+
$data['theme_theme_id'] = null;
126+
}
118127
return $data;
119128
}
120129
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Theme\Controller\Adminhtml\System\Design\Config;
8+
9+
use Magento\Framework\Data\Form\FormKey;
10+
use Magento\TestFramework\TestCase\AbstractBackendController;
11+
12+
/**
13+
* Class SaveTest @covers \Magento\Theme\Controller\Adminhtml\Design\Config\Save
14+
*/
15+
class SaveTest extends AbstractBackendController
16+
{
17+
/**
18+
* @inheritdoc
19+
*/
20+
protected $resource = 'Magento_Config::config_design';
21+
22+
/**
23+
* @inheritdoc
24+
*/
25+
protected $uri = 'backend/theme/design_config/save';
26+
27+
/**
28+
* Test design configuration save valid values.
29+
*
30+
* @return void
31+
*/
32+
public function testSave()
33+
{
34+
$params = $this->getRequestParams();
35+
$this->getRequest()->setParams($params);
36+
$error = '';
37+
try {
38+
$this->dispatch($this->uri);
39+
} catch (\Exception $e) {
40+
$error = $e->getMessage();
41+
}
42+
43+
self::assertEmpty($error, $error);
44+
}
45+
46+
/**
47+
* Provide test request params for testSave().
48+
*
49+
* @return array
50+
*/
51+
private function getRequestParams()
52+
{
53+
return [
54+
'theme_theme_id' => '',
55+
'pagination_pagination_frame' => '5',
56+
'pagination_pagination_frame_skip' => '',
57+
'pagination_anchor_text_for_previous' => '',
58+
'pagination_anchor_text_for_next' => '',
59+
'head_default_title' => 'Magento Commerce',
60+
'head_title_prefix' => '',
61+
'head_title_suffix' => '',
62+
'head_default_description' => '',
63+
'head_default_keywords' => '',
64+
'head_includes' => '',
65+
'head_demonotice' => '0',
66+
'header_logo_width' => '',
67+
'header_logo_height' => '',
68+
'header_logo_alt' => '',
69+
'header_welcome' => 'Default welcome msg!',
70+
'footer_copyright' => 'Copyright © 2013-2017 Magento, Inc. All rights reserved.',
71+
'footer_absolute_footer' => '',
72+
'default_robots' => 'INDEX,FOLLOW',
73+
'custom_instructions' => '',
74+
'watermark_image_size' => '',
75+
'watermark_image_imageOpacity' => '',
76+
'watermark_image_position' => 'stretch',
77+
'watermark_small_image_size' => '',
78+
'watermark_small_image_imageOpacity' => '',
79+
'watermark_small_image_position' => 'stretch',
80+
'watermark_thumbnail_size' => '',
81+
'watermark_thumbnail_imageOpacity' => '',
82+
'watermark_thumbnail_position' => 'stretch',
83+
'email_logo_alt' => 'test',
84+
'email_logo_width' => '200',
85+
'email_logo_height' => '100',
86+
'email_header_template' => 'design_email_header_template',
87+
'email_footer_template' => 'design_email_footer_template',
88+
'watermark_swatch_image_size' => '',
89+
'watermark_swatch_image_imageOpacity' => '',
90+
'watermark_swatch_image_position' => 'stretch',
91+
'scope' => 'default',
92+
'form_key' => $this->_objectManager->get(FormKey::class)->getFormKey(),
93+
];
94+
}
95+
}

0 commit comments

Comments
 (0)