diff --git a/app/code/Magento/Config/Model/Config/Backend/Encrypted.php b/app/code/Magento/Config/Model/Config/Backend/Encrypted.php index 9f4f57e5433b7..a7058afe57e44 100644 --- a/app/code/Magento/Config/Model/Config/Backend/Encrypted.php +++ b/app/code/Magento/Config/Model/Config/Backend/Encrypted.php @@ -93,6 +93,8 @@ public function beforeSave() $this->_dataSaveAllowed = true; $encrypted = $this->_encryptor->encrypt($value); $this->setValue($encrypted); + } elseif (empty($value)) { + $this->_dataSaveAllowed = true; } } diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/EncryptedTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/EncryptedTest.php index ed284eb16dd41..7dd299e6ae2bd 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Backend/EncryptedTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Backend/EncryptedTest.php @@ -92,8 +92,6 @@ public function testProcessValue() */ public function testBeforeSave($value, $expectedValue, $encryptMethodCall) { - $this->_resourceMock->expects($this->any())->method('addCommitCallback')->will($this->returnSelf()); - $this->_resourceMock->expects($this->any())->method('commit')->will($this->returnSelf()); $this->_encryptorMock->expects($this->exactly($encryptMethodCall)) ->method('encrypt') ->with($value) @@ -113,4 +111,15 @@ public function beforeSaveDataProvider() { return [['someValue', 'encrypted', 1], ['****', '****', 0]]; } + + /** + * @covers \Magento\Config\Model\Config\Backend\Encrypted::beforeSave + */ + public function testAllowEmptySave() + { + $this->_model->setValue(''); + $this->_model->setPath('some/path'); + $this->_model->beforeSave(); + $this->assertTrue($this->_model->isSaveAllowed()); + } }