From 60b30c66199bf1f9e61097ac5ff91832a514fb39 Mon Sep 17 00:00:00 2001 From: Maksym Savich <msavich@ebay.com> Date: Fri, 17 Apr 2015 09:44:37 -0500 Subject: [PATCH] MAGETWO-35462: Refactor \Magento\Framework\Model\Resource\Db\AbstractDb only update changed fields - Failed integration test fix --- lib/internal/Magento/Framework/Model/AbstractModel.php | 2 ++ .../Magento/Framework/Model/Resource/Db/AbstractDb.php | 1 - .../Model/Test/Unit/Resource/Db/AbstractDbTest.php | 9 ++------- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/internal/Magento/Framework/Model/AbstractModel.php b/lib/internal/Magento/Framework/Model/AbstractModel.php index 3e96a6f32d1..fcd03252a41 100644 --- a/lib/internal/Magento/Framework/Model/AbstractModel.php +++ b/lib/internal/Magento/Framework/Model/AbstractModel.php @@ -305,8 +305,10 @@ abstract class AbstractModel extends \Magento\Framework\Object { $this->_beforeLoad($modelId, $field); $this->_getResource()->load($this, $modelId, $field); + $this->_afterLoad(); $this->setOrigData(); $this->_hasDataChanges = false; + $this->updateStoredData(); return $this; } diff --git a/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php b/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php index 1c65431f1f9..351365b08d9 100644 --- a/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php +++ b/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php @@ -365,7 +365,6 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso $this->unserializeFields($object); $this->_afterLoad($object); - $object->afterLoad(); return $this; } diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/Resource/Db/AbstractDbTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/Resource/Db/AbstractDbTest.php index 9429fe7e0dc..66b3fd9ffcd 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/Resource/Db/AbstractDbTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/Resource/Db/AbstractDbTest.php @@ -278,20 +278,15 @@ class AbstractDbTest extends \PHPUnit_Framework_TestCase { $contextMock = $this->getMock('\Magento\Framework\Model\Context', [], [], '', false); $registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false); - $resourceMock = $this->getMock('Magento\Framework\Model\Resource\Db\AbstractDb', ['_construct'], [], '', false); $abstractModelMock = $this->getMockForAbstractClass( '\Magento\Framework\Model\AbstractModel', - [$contextMock, $registryMock, $resourceMock], + [$contextMock, $registryMock], '', false, true, true, - ['__wakeup', 'getResource', '_afterLoad'] + ['__wakeup'] ); - $abstractModelMock->expects($this->any()) - ->method('getResource') - ->will($this->returnValue($resourceMock)); - $abstractModelMock->expects($this->once())->method('_afterLoad'); $value = 'some_value'; $idFieldName = new \ReflectionProperty('Magento\Framework\Model\Resource\Db\AbstractDb', '_idFieldName'); -- GitLab