Esempio n. 1
0
 public function testDelete()
 {
     $dbAdapter = $this->getMock('Magento\\Framework\\DB\\Adapter\\AdapterInterface');
     $this->resource->expects($this->once())->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 = 1;
     $this->customerHelper->expects($this->once())->method('getDefaultCustomerGroupId')->will($this->returnValue($defaultCustomerGroup));
     $customer->expects($this->once())->method('setGroupId')->with($defaultCustomerGroup);
     $customerCollection = $this->getMock('Magento\\Customer\\Model\\Resource\\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->groupResourceModel->delete($this->groupModel);
 }