Skip to content

Commit

Permalink
Merge forwardport of #12328 to 2.3-develop branch
Browse files Browse the repository at this point in the history
Applied pull request patch https://github.com/magento/magento2/pull/12328.patch (created by @RomaKis) based on commit(s):
  1. 147f638

Fixed GitHub Issues in 2.3-develop branch:
  - #9742: Default welcome message returns after being deleted (reported by @robgt)
  • Loading branch information
magento-engcom-team authored Jan 24, 2018
2 parents 2d910df + 0c799d2 commit 57c355a
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/code/Magento/Theme/Model/Design/Config/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ public function load($scope, $scopeId)
$scopeId,
$fieldData->getFieldConfig()
);
if ($value !== null) {
$fieldData->setValue($value);

if ($value === null) {
$value = '';
}
$fieldData->setValue($value);
}

return $designConfig;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Theme\Model\Design;

/**
* Test for \Magento\Theme\Model\Design\Config\Storage.
*/
class ConfigTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Theme\Model\Design\Config\Storage
*/
private $storage;

protected function setUp()
{
$this->storage = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
\Magento\Theme\Model\Design\Config\Storage::class
);
}

/**
* Test design/header/welcome if it is saved in db as empty(null) it should be shown on backend as empty.
*
* @magentoDataFixture Magento/Theme/_files/config_data.php
*/
public function testLoad()
{
$data = $this->storage->load('stores', 1);
foreach ($data->getExtensionAttributes()->getDesignConfigData() as $configData) {
if ($configData->getPath() == 'design/header/welcome') {
$this->assertSame('', $configData->getValue());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

use Magento\Config\Model\Config\Factory;
use Magento\TestFramework\Helper\Bootstrap;

$objectManager = Bootstrap::getObjectManager();

/** @var Factory $configFactory */
$configFactory = $objectManager->create(Factory::class);
/** @var \Magento\Config\Model\Config $config */
$config = $configFactory->create();
$config->setScope('stores');
$config->setStore('default');
$config->setDataByPath('design/header/welcome', null);
$config->save();
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/** @var \Magento\Framework\App\ResourceConnection $resource */
$resource = $objectManager->get(\Magento\Framework\App\ResourceConnection::class);
$connection = $resource->getConnection();
$tableName = $resource->getTableName('core_config_data');

$connection->query("DELETE FROM $tableName WHERE path = 'design/header/welcome';");

0 comments on commit 57c355a

Please sign in to comment.