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)); }
/** * Create a test group. * * @param CustomerGroup $group The group to create and save. * @return int The group Id of the group that was created. */ private function createGroup($group) { $groupId = $this->groupRepository->save($group)->getId(); $this->assertNotNull($groupId); $newGroup = $this->groupRepository->getById($groupId); $this->assertEquals($groupId, $newGroup->getId(), 'The group id does not match.'); $this->assertEquals($group->getCode(), $newGroup->getCode(), 'The group code does not match.'); $this->assertEquals($group->getTaxClassId(), $newGroup->getTaxClassId(), 'The group tax class id does not match.'); $this->groupRegistry->remove($groupId); return $groupId; }
public function testCustomerLoggedIn() { $this->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->willReturn(true); $this->cacheConfigMock->expects($this->once())->method('isEnabled')->willReturn(true); $this->taxHelperMock->expects($this->any())->method('isCatalogPriceDisplayAffectedByTax')->willReturn(true); $customerMock = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\Customer')->disableOriginalConstructor()->getMock(); $this->observerMock->expects($this->once())->method('getData')->with('customer')->willReturn($customerMock); $customerMock->expects($this->once())->method('getGroupId')->willReturn(1); $customerGroupMock = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\Group')->disableOriginalConstructor()->getMock(); $this->groupRepositoryMock->expects($this->once())->method('getById')->with(1)->willReturn($customerGroupMock); $customerGroupMock->expects($this->once())->method('getTaxClassId')->willReturn(1); $this->customerSessionMock->expects($this->once())->method('setCustomerTaxClassId')->with(1); $address = $this->objectManager->getObject('Magento\\Customer\\Model\\Data\\Address'); $address->setIsDefaultShipping(true); $address->setIsDefaultBilling(true); $address->setCountryId(1); $address->setPostCode(11111); $addresses = [$address]; $customerMock->expects($this->once())->method('getAddresses')->willReturn($addresses); $this->customerSessionMock->expects($this->once())->method('setDefaultTaxBillingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]); $this->customerSessionMock->expects($this->once())->method('setDefaultTaxShippingAddress')->with(['country_id' => 1, 'region_id' => null, 'postcode' => 11111]); $this->session->customerLoggedIn($this->observerMock); }