/** * @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()); }
/** * @covers \Magento\Config\Model\Config\Backend\Encrypted::beforeSave * @dataProvider beforeSaveDataProvider * * @param string $value * @param string $expectedValue * @param int $encryptMethodCall */ 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)->will($this->returnValue('encrypted')); $this->_model->setValue($value); $this->_model->setPath('some/path'); $this->_model->beforeSave(); $this->assertEquals($expectedValue, $this->_model->getValue()); }
/** * @covers \Magento\Config\Model\Config\Backend\Encrypted::beforeSave * @dataProvider beforeSaveDataProvider * * @param $value * @param $valueToSave */ public function testBeforeSave($value, $valueToSave) { $this->_resourceMock->expects($this->any())->method('addCommitCallback')->will($this->returnSelf()); $this->_resourceMock->expects($this->any())->method('commit')->will($this->returnSelf()); $this->_configMock->expects($this->any())->method('getValue')->with('some/path')->will($this->returnValue('oldValue')); $this->_encryptorMock->expects($this->once())->method('encrypt')->with($valueToSave)->will($this->returnValue('encrypted')); $this->_model->setValue($value); $this->_model->setPath('some/path'); $this->_model->beforeSave(); $this->assertEquals($this->_model->getValue(), 'encrypted'); }