public function testSave()
 {
     $this->entitySnapshotMock->expects($this->once())->method('isModified')->with($this->addressMock)->willReturn(true);
     $this->entitySnapshotMock->expects($this->once())->method('registerSnapshot')->with($this->addressMock);
     $this->relationCompositeMock->expects($this->once())->method('processRelations')->with($this->addressMock);
     $this->addressResource->save($this->addressMock);
 }
Exemple #2
0
 public function testSave()
 {
     $this->orderMock->expects($this->exactly(3))->method('getId')->willReturn(null);
     $this->orderItemMock->expects($this->once())->method('getChildrenItems')->willReturn([]);
     $this->orderItemMock->expects($this->once())->method('getQuoteParentItemId')->willReturn(null);
     $this->orderMock->expects($this->once())->method('setTotalItemCount')->with(1);
     $this->storeGroupMock->expects($this->once())->method('getDefaultStoreId')->willReturn(1);
     $this->orderMock->expects($this->once())->method('getAllItems')->willReturn([$this->orderItemMock]);
     $this->orderMock->expects($this->once())->method('validateBeforeSave')->willReturnSelf();
     $this->orderMock->expects($this->once())->method('beforeSave')->willReturnSelf();
     $this->orderMock->expects($this->once())->method('isSaveAllowed')->willReturn(true);
     $this->orderMock->expects($this->once())->method('getEntityType')->willReturn('order');
     $this->orderMock->expects($this->exactly(2))->method('getStore')->willReturn($this->storeMock);
     $this->storeMock->expects($this->exactly(2))->method('getGroup')->willReturn($this->storeGroupMock);
     $this->storeMock->expects($this->once())->method('getWebsite')->willReturn($this->websiteMock);
     $this->storeGroupMock->expects($this->once())->method('getDefaultStoreId')->willReturn(1);
     $this->salesSequenceManagerMock->expects($this->once())->method('getSequence')->with('order', 1)->willReturn($this->salesSequenceMock);
     $this->salesSequenceMock->expects($this->once())->method('getNextValue')->willReturn('10000001');
     $this->orderMock->expects($this->once())->method('setIncrementId')->with('10000001')->willReturnSelf();
     $this->orderMock->expects($this->once())->method('getIncrementId')->willReturn(null);
     $this->orderMock->expects($this->once())->method('getData')->willReturn(['increment_id' => '10000001']);
     $this->objectRelationProcessorMock->expects($this->once())->method('validateDataIntegrity')->with(null, ['increment_id' => '10000001']);
     $this->relationCompositeMock->expects($this->once())->method('processRelations')->with($this->orderMock);
     $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->connectionMock);
     $this->connectionMock->expects($this->any())->method('quoteInto');
     $this->connectionMock->expects($this->any())->method('describeTable')->will($this->returnValue([]));
     $this->connectionMock->expects($this->any())->method('update');
     $this->connectionMock->expects($this->any())->method('lastInsertId');
     $this->orderMock->expects($this->any())->method('getId')->will($this->returnValue(1));
     $this->entitySnapshotMock->expects($this->once())->method('isModified')->with($this->orderMock)->will($this->returnValue(true));
     $this->resource->save($this->orderMock);
 }
 /**
  * @param $addressId
  * @param $isDefaultBilling
  * @param $isDefaultShipping
  *
  * @dataProvider getSaveDataProvider
  */
 public function testSave($addressId, $isDefaultBilling, $isDefaultShipping)
 {
     /** @var $address \Magento\Customer\Model\Address|\PHPUnit_Framework_MockObject_MockObject */
     $address = $this->getMock('Magento\\Customer\\Model\\Address', ['__wakeup', 'getId', 'getEntityTypeId', 'getIsDefaultBilling', 'getIsDefaultShipping', 'hasDataChanges', 'validateBeforeSave', 'beforeSave', 'afterSave', 'isSaveAllowed'], [], '', false);
     $this->entitySnapshotMock->expects($this->once())->method('isModified')->willReturn(true);
     $this->entityRelationCompositeMock->expects($this->once())->method('processRelations');
     $address->expects($this->once())->method('isSaveAllowed')->willReturn(true);
     $address->expects($this->once())->method('validateBeforeSave');
     $address->expects($this->once())->method('beforeSave');
     $address->expects($this->once())->method('afterSave');
     $address->expects($this->any())->method('getEntityTypeId')->willReturn('3');
     $address->expects($this->any())->method('getId')->willReturn($addressId);
     $address->expects($this->any())->method('getIsDefaultShipping')->willReturn($isDefaultShipping);
     $address->expects($this->any())->method('getIsDefaultBilling')->willReturn($isDefaultBilling);
     $this->addressResource->setType('customer_address');
     $this->addressResource->save($address);
 }
 public function testSaveNotModified()
 {
     $objectManager = new ObjectManager($this);
     /** @var $object \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */
     $object = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false);
     $arguments = $objectManager->getConstructArguments('Magento\\Eav\\Model\\Entity\\VersionControl\\AbstractEntity', ['entitySnapshot' => $this->entitySnapshot, 'entityRelationComposite' => $this->entityRelationComposite]);
     /** @var $model AbstractEntity|\PHPUnit_Framework_MockObject_MockObject */
     $model = $this->getMockBuilder('Magento\\Eav\\Model\\Entity\\VersionControl\\AbstractEntity')->setConstructorArgs($arguments)->setMethods(['beginTransaction', 'commit'])->getMock();
     $this->entitySnapshot->expects($this->once())->method('isModified')->willReturn(false);
     $this->entitySnapshot->expects($this->never())->method('registerSnapshot');
     $this->entityRelationComposite->expects($this->once())->method('processRelations')->with($object);
     $model->save($object);
 }