当前位置: 首页>>代码示例>>PHP>>正文


PHP GroupRepositoryInterface::expects方法代码示例

本文整理汇总了PHP中Magento\Customer\Api\GroupRepositoryInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP GroupRepositoryInterface::expects方法的具体用法?PHP GroupRepositoryInterface::expects怎么用?PHP GroupRepositoryInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Customer\Api\GroupRepositoryInterface的用法示例。


在下文中一共展示了GroupRepositoryInterface::expects方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetCustomerGroupAttribute

 /**
  * @covers \Magento\Sales\Ui\Component\DataProvider\Document::getCustomAttribute
  */
 public function testGetCustomerGroupAttribute()
 {
     $this->document->setData('customer_group_id', 1);
     $group = $this->getMockForAbstractClass(GroupInterface::class);
     $this->groupRepository->expects(static::once())->method('getById')->willReturn($group);
     $group->expects(static::once())->method('getCode')->willReturn('General');
     $attribute = $this->document->getCustomAttribute('customer_group_id');
     static::assertEquals('General', $attribute->getValue());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:DocumentTest.php

示例2: processInit

 protected function processInit($groupId)
 {
     $searchResult = $this->getMock('Magento\\Customer\\Api\\Data\\GroupSearchResultsInterface', [], [], '', false);
     $this->groupRepositoryInterface->expects($this->once())->method('getList')->willReturn($searchResult);
     $group = $this->getMock('Magento\\Customer\\Model\\Data\\Group', [], [], '', false);
     $group->expects($this->once())->method('getId')->willReturn($groupId);
     $searchResult->expects($this->once())->method('getItems')->willReturn([$group]);
     return $this->tierPrice->init(null);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:TierPriceTest.php

示例3: testPrepareDataSource

 public function testPrepareDataSource()
 {
     $itemName = 'itemName';
     $oldItemValue = 'oldItemValue';
     $newItemValue = 'newItemValue';
     $dataSource = ['data' => ['items' => [[$itemName => $oldItemValue]]]];
     $group = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\GroupInterface');
     $group->expects($this->once())->method('getCode')->willReturn($newItemValue);
     $this->groupRepository->expects($this->once())->method('getById')->with($oldItemValue)->willReturn($group);
     $this->model->setData('name', $itemName);
     $dataSource = $this->model->prepareDataSource($dataSource);
     $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:13,代码来源:CustomerGroupTest.php

示例4: testToOptionArray

 public function testToOptionArray()
 {
     $customerGroups = [['label' => __('ALL GROUPS'), 'value' => 32000], ['label' => __('NOT LOGGED IN'), 'value' => 0]];
     $this->moduleManagerMock->expects($this->any())->method('isEnabled')->willReturn(true);
     $this->searchCriteriaBuilderMock->expects($this->any())->method('create')->willReturn($this->searchCriteriaMock);
     $this->groupRepositoryMock->expects($this->any())->method('getList')->with($this->searchCriteriaMock)->willReturn($this->searchResultMock);
     $this->groupRepositoryMock->expects($this->any())->method('getList')->with($this->searchCriteriaMock)->willReturn($this->searchResultMock);
     $groupTest = $this->getMockBuilder('\\Magento\\Customer\\Api\\Data\\GroupInterface')->disableOriginalConstructor()->setMethods(['getCode', 'getId'])->getMockForAbstractClass();
     $groupTest->expects($this->any())->method('getCode')->willReturn(__('NOT LOGGED IN'));
     $groupTest->expects($this->any())->method('getId')->willReturn(0);
     $groups = [$groupTest];
     $this->searchResultMock->expects($this->any())->method('getItems')->willReturn($groups);
     $this->assertEquals($customerGroups, $this->model->toOptionArray());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:GroupTest.php

示例5: testSetAccountData

 public function testSetAccountData()
 {
     $taxClassId = 1;
     $attributes = [['email', 'user@example.com'], ['group_id', 1]];
     $attributeMocks = [];
     foreach ($attributes as $attribute) {
         $attributeMock = $this->getMock('Magento\\Customer\\Api\\Data\\AttributeMetadataInterface', [], [], '', false);
         $attributeMock->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attribute[0]));
         $attributeMocks[] = $attributeMock;
     }
     $customerGroupMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\GroupInterface', [], '', false, true, true, ['getTaxClassId']);
     $customerGroupMock->expects($this->once())->method('getTaxClassId')->will($this->returnValue($taxClassId));
     $customerFormMock = $this->getMock('Magento\\Customer\\Model\\Metadata\\Form', [], [], '', false);
     $customerFormMock->expects($this->any())->method('getAttributes')->will($this->returnValue($attributeMocks));
     $customerFormMock->expects($this->any())->method('extractData')->will($this->returnValue([]));
     $customerFormMock->expects($this->any())->method('restoreData')->will($this->returnValue([]));
     $customerFormMock->expects($this->any())->method('prepareRequest')->will($this->returnValue($this->getMock('Magento\\Framework\\App\\RequestInterface')));
     $customerMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
     $this->customerMapper->expects($this->atLeastOnce())->method('toFlatArray')->willReturn(['email' => 'user@example.com', 'group_id' => 1, 'gender' => 1]);
     $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
     $quoteMock->expects($this->any())->method('getCustomer')->will($this->returnValue($customerMock));
     $quoteMock->expects($this->once())->method('addData')->with(['customer_email' => $attributes[0][1], 'customer_group_id' => $attributes[1][1], 'customer_tax_class_id' => $taxClassId]);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with($customerMock, ['email' => 'user@example.com', 'group_id' => 1, 'gender' => 1], '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
     $this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerFormMock));
     $this->sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock));
     $this->customerFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerMock));
     $this->groupRepositoryMock->expects($this->once())->method('getById')->will($this->returnValue($customerGroupMock));
     $this->adminOrderCreate->setAccountData([]);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:29,代码来源:CreateTest.php

示例6: testInitAddToCustomerGroups

 public function testInitAddToCustomerGroups()
 {
     $searchCriteria = $this->getMock('Magento\\Framework\\Api\\SearchCriteria', [], [], '', false);
     $this->searchCriteriaBuilder->expects($this->once())->method('create')->willReturn($searchCriteria);
     $groupSearchResult = $this->getMockForAbstractClass('\\Magento\\Customer\\Api\\Data\\GroupSearchResultsInterface', [], '', false);
     $this->groupRepository->expects($this->once())->method('getList')->with($searchCriteria)->willReturn($groupSearchResult);
     $groupTest = $this->getMockBuilder('\\Magento\\Customer\\Api\\Data\\GroupInterface')->disableOriginalConstructor()->setMethods(['getCode', 'getId'])->getMockForAbstractClass();
     $expectedCode = 'code';
     $expectedId = 'id';
     $expectedCustomerGroups = [$expectedCode => $expectedId];
     $groupTest->expects($this->once())->method('getCode')->willReturn($expectedCode);
     $groupTest->expects($this->once())->method('getId')->willReturn($expectedId);
     $groups = [$groupTest];
     $groupSearchResult->expects($this->once())->method('getItems')->willReturn($groups);
     $this->groupPrice->init();
     $this->assertEquals($expectedCustomerGroups, $this->getPropertyValue($this->groupPrice, 'customerGroups'));
 }
开发者ID:nja78,项目名称:magento2,代码行数:17,代码来源:GroupPriceTest.php

示例7: testExecuteWithTaxClassAndException

 public function testExecuteWithTaxClassAndException()
 {
     $taxClass = '3';
     $groupId = 0;
     $code = 'NOT LOGGED IN';
     $this->request->expects($this->exactly(3))->method('getParam')->withConsecutive(['tax_class'], ['id'], ['code'])->willReturnOnConsecutiveCalls($taxClass, $groupId, null);
     $this->resultRedirectFactory->expects($this->once())->method('create')->willReturn($this->resultRedirect);
     $this->groupRepositoryMock->expects($this->once())->method('getById')->with($groupId)->willReturn($this->group);
     $this->group->expects($this->once())->method('getCode')->willReturn($code);
     $this->group->expects($this->once())->method('setCode')->with($code);
     $this->group->expects($this->once())->method('setTaxClassId')->with($taxClass);
     $this->groupRepositoryMock->expects($this->once())->method('save')->with($this->group);
     $this->messageManager->expects($this->once())->method('addSuccess')->with(__('You saved the customer group.'));
     $exception = new \Exception('Exception');
     $this->resultRedirect->expects($this->at(0))->method('setPath')->with('customer/group')->willThrowException($exception);
     $this->messageManager->expects($this->once())->method('addError')->with('Exception');
     $this->dataObjectProcessorMock->expects($this->once())->method('buildOutputDataArray')->with($this->group, '\\Magento\\Customer\\Api\\Data\\GroupInterface')->willReturn(['code' => $code]);
     $this->session->expects($this->once())->method('setCustomerGroupData')->with(['customer_group_code' => $code]);
     $this->resultRedirect->expects($this->at(1))->method('setPath')->with('customer/group/edit', ['id' => $groupId]);
     $this->assertSame($this->resultRedirect, $this->controller->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:21,代码来源:SaveTest.php

示例8: testGetWebsiteAttribute

 /**
  * @covers \Magento\Customer\Ui\Component\DataProvider\Document::getCustomAttribute
  */
 public function testGetWebsiteAttribute()
 {
     $websiteId = 1;
     $this->document->setData('website_id', $websiteId);
     $this->groupRepository->expects(static::never())->method('getById');
     $this->customerMetadata->expects(static::never())->method('getAttributeMetadata');
     $website = $this->getMockForAbstractClass(WebsiteInterface::class);
     $this->storeManager->expects(static::once())->method('getWebsites')->willReturn([$websiteId => $website]);
     $website->expects(static::once())->method('getName')->willReturn('Main Website');
     $attribute = $this->document->getCustomAttribute('website_id');
     static::assertEquals('Main Website', $attribute->getValue());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:DocumentTest.php

示例9: testIsValidAddMessagesCall

 /**
  * @dataProvider isValidAddMessagesCallDataProvider
  *
  * @param array $value
  * @param bool  $hasEmptyColumns
  * @param array $customerGroups
  * @param array $expectedMessages
  */
 public function testIsValidAddMessagesCall($value, $hasEmptyColumns, $customerGroups, $expectedMessages)
 {
     $priceContextMock = $this->getMock('\\Magento\\CatalogImportExport\\Model\\Import\\Product', [], ['\\Magento\\Framework\\Json\\Helper\\Data', '\\Magento\\ImportExport\\Helper\\Data', '\\Magento\\ImportExport\\Model\\ResourceModel\\Import\\Data', '\\Magento\\Eav\\Model\\Config', '\\Magento\\Framework\\App\\ResourceConnection', '\\Magento\\ImportExport\\Model\\ResourceModel\\Helper', '\\Magento\\Framework\\Stdlib\\StringUtils', 'ProcessingErrorAggregatorInterface'], '', false);
     $this->tierPrice->expects($this->once())->method('isValidValueAndLength')->willReturn(true);
     $this->tierPrice->expects($this->any())->method('hasEmptyColumns')->willReturn($hasEmptyColumns);
     $this->setPropertyValue($this->tierPrice, 'customerGroups', $customerGroups);
     $searchCriteria = $this->getMock('Magento\\Framework\\Api\\SearchCriteria', [], [], '', false);
     $this->searchCriteriaBuilder->expects($this->any())->method('create')->willReturn($searchCriteria);
     $groupSearchResult = $this->getMockForAbstractClass('\\Magento\\Customer\\Api\\Data\\GroupSearchResultsInterface', [], '', false);
     $this->groupRepository->expects($this->any())->method('getList')->with($searchCriteria)->willReturn($groupSearchResult);
     $groupTest = $this->getMockBuilder('\\Magento\\Customer\\Api\\Data\\GroupInterface')->disableOriginalConstructor()->setMethods(['getCode', 'getId'])->getMockForAbstractClass();
     $groupTest->expects($this->once())->method('getCode');
     $groupTest->expects($this->any())->method('getId');
     $groups = [$groupTest];
     $groupSearchResult->expects($this->any())->method('getItems')->willReturn($groups);
     $this->tierPrice->init($priceContextMock);
     $this->tierPrice->isValid($value);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:26,代码来源:TierPriceTest.php


注:本文中的Magento\Customer\Api\GroupRepositoryInterface::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。