public function testDelete()
 {
     $groupId = 6;
     $this->group->expects($this->once())->method('getId')->willReturn($groupId);
     $this->groupRegistry->expects($this->once())->method('retrieve')->with($groupId)->willReturn($this->groupModel);
     $this->groupModel->expects($this->once())->method('usesAsDefault')->willReturn(false);
     $this->groupModel->expects($this->once())->method('delete');
     $this->groupRegistry->expects($this->once())->method('remove')->with($groupId);
     $this->assertTrue($this->model->delete($this->group));
 }
Beispiel #2
0
 public function testDelete()
 {
     $dbAdapter = $this->getMock('Magento\\Framework\\DB\\Adapter\\AdapterInterface');
     $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($dbAdapter));
     $customer = $this->getMock('Magento\\Customer\\Model\\Customer', ['__wakeup', 'load', 'getId', 'getStoreId', 'setGroupId', 'save'], [], '', false);
     $customerId = 1;
     $customer->expects($this->once())->method('getId')->will($this->returnValue($customerId));
     $customer->expects($this->once())->method('load')->with($customerId)->will($this->returnSelf());
     $defaultCustomerGroup = $this->getMock('Magento\\Customer\\Model\\Group', ['getId'], [], '', false);
     $this->groupManagement->expects($this->once())->method('getDefaultGroup')->will($this->returnValue($defaultCustomerGroup));
     $defaultCustomerGroup->expects($this->once())->method('getId')->will($this->returnValue(1));
     $customer->expects($this->once())->method('setGroupId')->with(1);
     $customerCollection = $this->getMock('Magento\\Customer\\Model\\ResourceModel\\Customer\\Collection', [], [], '', false);
     $customerCollection->expects($this->once())->method('addAttributeToFilter')->will($this->returnSelf());
     $customerCollection->expects($this->once())->method('load')->will($this->returnValue([$customer]));
     $this->customersFactory->expects($this->once())->method('create')->will($this->returnValue($customerCollection));
     $this->relationProcessorMock->expects($this->once())->method('delete');
     $this->groupModel->expects($this->any())->method('getData')->willReturn(['data' => 'value']);
     $this->groupResourceModel->delete($this->groupModel);
 }