コード例 #1
0
 /**
  * @dataProvider hasDataChangedDataProvider
  * @param string $getOriginData
  * @param bool $expected
  */
 public function testGetDataChanged($getOriginData, $expected)
 {
     $adapterInterfaceMock = $this->getMock('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface', [], [], '', false);
     $this->_resourcesMock->expects($this->any())->method('getConnection')->will($this->returnValue($adapterInterfaceMock));
     $contextMock = $this->getMock('\\Magento\\Framework\\Model\\Context', [], [], '', false);
     $registryMock = $this->getMock('\\Magento\\Framework\\Registry', [], [], '', false);
     $abstractModelMock = $this->getMockForAbstractClass('\\Magento\\Framework\\Model\\AbstractModel', [$contextMock, $registryMock], '', false, true, true, ['__wakeup', 'getOrigData', 'getData']);
     $mainTableProperty = new \ReflectionProperty('Magento\\Framework\\Model\\Resource\\Db\\AbstractDb', '_mainTable');
     $mainTableProperty->setAccessible(true);
     $mainTableProperty->setValue($this->_model, 'table');
     $this->_resourcesMock->expects($this->once())->method('getTableName')->with('table')->will($this->returnValue('tableName'));
     $abstractModelMock->expects($this->at(0))->method('getOrigData')->will($this->returnValue(true));
     $abstractModelMock->expects($this->at(1))->method('getOrigData')->will($this->returnValue($getOriginData));
     $adapterInterfaceMock->expects($this->any())->method('describeTable')->with('tableName')->will($this->returnValue(['tableName']));
     $this->assertEquals($expected, $this->_model->hasDataChanged($abstractModelMock));
 }