public function testIsValueChanged() { // load the model $collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Core\\Model\\Resource\\Config\\Data\\Collection'); $collection->addFieldToFilter('path', self::SAMPLE_CONFIG_PATH)->addFieldToFilter('scope_id', 0)->addFieldToFilter('scope', 'default'); foreach ($collection as $configData) { $this->_model = $configData; break; } $this->assertNotEmpty($this->_model->getId()); // assert $this->assertFalse($this->_model->isValueChanged()); $this->_model->setValue(uniqid()); $this->assertTrue($this->_model->isValueChanged()); }
/** * @param int $callNumber * @param string $oldValue * @dataProvider afterSaveDataProvider */ public function testAfterSave($callNumber, $oldValue) { $this->cacheTypeListMock->expects($this->exactly($callNumber))->method('invalidate'); $this->configMock->expects($this->any())->method('getValue')->willReturn($oldValue); $this->model->setValue('some_value'); $this->assertInstanceOf(get_class($this->model), $this->model->afterSave()); }
/** * @param string $oldValue * @param string $value * @param bool $result * @dataProvider dataIsValueChanged */ public function testIsValueChanged($oldValue, $value, $result) { $this->configMock->expects($this->once())->method('getValue')->with(null, 'default')->will($this->returnValue($oldValue)); $this->model->setValue($value); $this->assertEquals($result, $this->model->isValueChanged()); }