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


PHP ExtensibleDataObjectConverter::expects方法代码示例

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


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

示例1: testToFlatArray

 public function testToFlatArray()
 {
     $expectedResultWithoutStreet = ['id' => 1, 'default_shipping' => false, 'default_billing' => true, 'firstname' => 'John', 'lastname' => 'Doe', 'city' => 'Austin', 'country_id' => 'US', 'region_id' => 1, 'region' => 'Texas', 'region_code' => 'TX'];
     $expectedResultWithStreet = array_merge($expectedResultWithoutStreet, ['street' => ['7700 W Parmer Ln', 'Austin, TX']]);
     $this->extensibleObjectConverter->expects($this->once())->method('toFlatArray')->willReturn($expectedResultWithoutStreet);
     $addressData = $this->createAddressMock();
     $result = $this->addressMapper->toFlatArray($addressData);
     $this->assertEquals($expectedResultWithStreet, $result);
 }
开发者ID:IlyaGluschenko,项目名称:protection,代码行数:9,代码来源:MapperTest.php

示例2: setUp

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->addressRepositoryMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\AddressRepositoryInterface', ['get'], '', false);
     $this->accountManagementMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\AccountManagementInterface', [], '', false);
     $this->eventManagerMock = $this->getMock('Magento\\Framework\\Event\\ManagerInterface');
     $this->checkoutHelperMock = $this->getMock('Magento\\Checkout\\Helper\\Data', [], [], '', false);
     $this->customerUrlMock = $this->getMock('Magento\\Customer\\Model\\Url', [], [], '', false);
     $this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->checkoutSessionMock = $this->getMock('Magento\\Checkout\\Model\\Session', ['getLastOrderId', 'getQuote', 'setStepData', 'getStepData'], [], '', false);
     $this->customerSessionMock = $this->getMock('Magento\\Customer\\Model\\Session', ['getCustomerDataObject', 'isLoggedIn'], [], '', false);
     $this->storeManagerMock = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface');
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->addressFactoryMock = $this->getMock('Magento\\Customer\\Model\\AddressFactory', [], [], '', false);
     $this->formFactoryMock = $this->getMock('Magento\\Customer\\Model\\Metadata\\FormFactory', [], [], '', false);
     $this->customerFactoryMock = $this->getMock('Magento\\Customer\\Model\\CustomerFactory', [], [], '', false);
     $this->quoteManagementMock = $this->getMock('Magento\\Quote\\Model\\QuoteManagement', [], [], '', false);
     $this->orderFactoryMock = $this->getMock('Magento\\Sales\\Model\\OrderFactory', ['create'], [], '', false);
     $this->copyMock = $this->getMock('Magento\\Framework\\Object\\Copy', [], [], '', false);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\ManagerInterface');
     $this->customerFormFactoryMock = $this->getMock('Magento\\Customer\\Model\\FormFactory', ['create'], [], '', false);
     $this->customerDataFactoryMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterfaceFactory', [], [], '', false);
     $this->randomMock = $this->getMock('Magento\\Framework\\Math\\Random');
     $this->encryptorMock = $this->getMock('Magento\\Framework\\Encryption\\EncryptorInterface');
     $this->customerRepositoryMock = $this->getMockForAbstractClass('\\Magento\\Customer\\Api\\CustomerRepositoryInterface', [], '', false);
     $orderSenderMock = $this->getMock('\\Magento\\Sales\\Model\\Order\\Email\\Sender\\OrderSender', [], [], '', false);
     $this->quoteRepositoryMock = $this->getMock('Magento\\Quote\\Model\\QuoteRepository', [], [], '', false);
     $this->extensibleDataObjectConverterMock = $this->getMockBuilder('Magento\\Framework\\Api\\ExtensibleDataObjectConverter')->setMethods(['toFlatArray'])->disableOriginalConstructor()->getMock();
     $this->extensibleDataObjectConverterMock->expects($this->any())->method('toFlatArray')->will($this->returnValue([]));
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->onepage = $this->objectManagerHelper->getObject('Magento\\Checkout\\Model\\Type\\Onepage', ['eventManager' => $this->eventManagerMock, 'helper' => $this->checkoutHelperMock, 'customerUrl' => $this->customerUrlMock, 'logger' => $this->loggerMock, 'checkoutSession' => $this->checkoutSessionMock, 'customerSession' => $this->customerSessionMock, 'storeManager' => $this->storeManagerMock, 'request' => $this->requestMock, 'customrAddrFactory' => $this->addressFactoryMock, 'customerFormFactory' => $this->customerFormFactoryMock, 'customerFactory' => $this->customerFactoryMock, 'orderFactory' => $this->orderFactoryMock, 'objectCopyService' => $this->copyMock, 'messageManager' => $this->messageManagerMock, 'formFactory' => $this->formFactoryMock, 'customerDataFactory' => $this->customerDataFactoryMock, 'mathRandom' => $this->randomMock, 'encryptor' => $this->encryptorMock, 'addressRepository' => $this->addressRepositoryMock, 'accountManagement' => $this->accountManagementMock, 'orderSenderMock' => $orderSenderMock, 'customerRepository' => $this->customerRepositoryMock, 'extensibleDataObjectConverter' => $this->extensibleDataObjectConverterMock, 'quoteRepository' => $this->quoteRepositoryMock, 'quoteManagement' => $this->quoteManagementMock]);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:34,代码来源:OnepageTest.php

示例3: testExecuteWithException

 public function testExecuteWithException()
 {
     $this->request->expects($this->once())->method('getPost')->willReturn(null);
     $this->form->expects($this->once())->method('setInvisibleIgnored');
     $this->form->expects($this->atLeastOnce())->method('extractData')->willReturn([]);
     $this->form->expects($this->never())->method('validateData');
     $this->extensibleDataObjectConverter->expects($this->once())->method('toFlatArray')->willReturn([]);
     $validationResult = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\ValidationResultsInterface', [], '', false, true, true);
     $error = $this->getMock('Magento\\Framework\\Message\\Error', [], [], '', false);
     $error->expects($this->once())->method('getText')->willReturn('Error text');
     $exception = $this->getMock('Magento\\Framework\\Validator\\Exception', [], [], '', false);
     $exception->expects($this->once())->method('getMessages')->willReturn([$error]);
     $validationResult->expects($this->once())->method('getMessages')->willThrowException($exception);
     $this->customerAccountManagement->expects($this->once())->method('validate')->willReturn($validationResult);
     $this->controller->execute();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:ValidateTest.php

示例4: _setupStoreMode

 /**
  * @param $customerData
  * @param $isSingleStoreMode
  * @param $canModifyCustomer
  *
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 private function _setupStoreMode($customerData, $isSingleStoreMode, $canModifyCustomer)
 {
     $backendSessionMock = $this->getMock('\\Magento\\Backend\\Model\\Session', ['getCustomerData'], [], '', false);
     $backendSessionMock->expects($this->any())->method('getCustomerData')->will($this->returnValue([]));
     $layoutMock = $this->getMock('\\Magento\\Framework\\View\\Layout\\Element\\Layout', ['createBlock'], [], '', false);
     $layoutMock->expects($this->at(0))->method('createBlock')->with('Magento\\Customer\\Block\\Adminhtml\\Edit\\Renderer\\Attribute\\Group')->will($this->returnValue($this->objectManagerHelper->getObject('Magento\\Customer\\Block\\Adminhtml\\Edit\\Renderer\\Attribute\\Group')));
     $layoutMock->expects($this->at(1))->method('createBlock')->with('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element')->will($this->returnValue($this->objectManagerHelper->getObject('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element')));
     if (empty($customerData['id'])) {
         $layoutMock->expects($this->at(2))->method('createBlock')->with('Magento\\Customer\\Block\\Adminhtml\\Edit\\Renderer\\Attribute\\Sendemail')->will($this->returnValue($this->objectManagerHelper->getObject('Magento\\Customer\\Block\\Adminhtml\\Edit\\Renderer\\Attribute\\Sendemail')));
     }
     $urlBuilderMock = $this->getMock('\\Magento\\Backend\\Model\\Url', ['getBaseUrl'], [], '', false);
     $urlBuilderMock->expects($this->once())->method('getBaseUrl')->will($this->returnValue('someUrl'));
     $storeManagerMock = $this->getMock('Magento\\Store\\Model\\StoreManager', [], [], '', false);
     $storeManagerMock->expects($this->any())->method('isSingleStoreMode')->will($this->returnValue($isSingleStoreMode));
     $customerObject = $this->getMock('\\Magento\\Customer\\Api\\Data\\CustomerInterface');
     if (!empty($customerData['id'])) {
         $customerObject->expects($this->any())->method('getId')->will($this->returnValue($customerData['id']));
     }
     $fieldset = $this->getMockBuilder('\\Magento\\Framework\\Data\\Form\\Element\\Fieldset')->setMethods(['getForm', 'addField', 'removeField'])->disableOriginalConstructor()->getMock();
     $accountForm = $this->getMockBuilder('Magento\\Framework\\Data\\Form')->setMethods(['create', 'addFieldset', 'getElement', 'setValues'])->disableOriginalConstructor()->getMock();
     $accountForm->expects($this->any())->method('addFieldset')->with('base_fieldset')->will($this->returnValue($fieldset));
     $accountForm->expects($this->any())->method('setValues')->will($this->returnValue($accountForm));
     $fieldset->expects($this->any())->method('getForm')->will($this->returnValue($accountForm));
     $formElement = $this->getMockBuilder('\\Magento\\Framework\\Data\\Form\\Element\\Select')->setMethods(['setRenderer', 'addClass', 'setDisabled'])->disableOriginalConstructor()->getMock();
     $formElement->expects($this->any())->method('setRenderer')->will($this->returnValue(null));
     $formElement->expects($this->any())->method('addClass')->will($this->returnValue(null));
     $formElement->expects($this->any())->method('setDisabled')->will($this->returnValue(null));
     $accountForm->expects($this->any())->method('getElement')->withAnyParameters()->will($this->returnValue($formElement));
     $fieldset->expects($this->any())->method('addField')->will($this->returnValue($formElement));
     $customerForm = $this->getMock('\\Magento\\Customer\\Model\\Metadata\\Form', ['getAttributes'], [], '', false);
     $customerForm->expects($this->any())->method('getAttributes')->will($this->returnValue([]));
     $this->contextMock->expects($this->any())->method('getBackendSession')->will($this->returnValue($backendSessionMock));
     $this->contextMock->expects($this->any())->method('getLayout')->will($this->returnValue($layoutMock));
     $this->contextMock->expects($this->any())->method('getUrlBuilder')->will($this->returnValue($urlBuilderMock));
     $this->contextMock->expects($this->any())->method('getStoreManager')->will($this->returnValue($storeManagerMock));
     $this->customerFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerObject));
     $this->dataObjectHelperMock->expects($this->once())->method('populateWithArray');
     $this->options->expects($this->any())->method('getNamePrefixOptions')->will($this->returnValue(['Pref1', 'Pref2']));
     $this->options->expects($this->any())->method('getNameSuffixOptions')->will($this->returnValue(['Suf1', 'Suf2']));
     $this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($accountForm));
     $this->extensibleDataObjectConverterMock->expects($this->any())->method('toFlatArray')->will($this->returnValue($customerData));
     $this->customerFormFactoryMock->expects($this->any())->method('create')->with('customer', 'adminhtml_customer', $this->extensibleDataObjectConverterMock->toFlatArray($customerObject, [], '\\Magento\\Customer\\Api\\Data\\CustomerInterface'))->will($this->returnValue($customerForm));
     $this->accountManagementMock->expects($this->any())->method('isReadOnly')->withAnyParameters()->will($this->returnValue(!$canModifyCustomer));
     $this->accountManagementMock->expects($this->any())->method('getConfirmationStatus')->withAnyParameters()->will($this->returnValue(AccountManagementInterface::ACCOUNT_CONFIRMED));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:52,代码来源:AccountTest.php

示例5: testSaveWithPasswordHash

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testSaveWithPasswordHash()
 {
     $customerId = 1;
     $storeId = 2;
     $passwordHash = 'ukfa4sdfa56s5df02asdf4rt';
     $this->prepareMocksForValidation(true);
     $region = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\RegionInterface', [], '', false);
     $address = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AddressInterface', [], '', false, false, true, ['setCustomerId', 'setRegion', 'getRegion', 'getId']);
     $address2 = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AddressInterface', [], '', false, false, true, ['setCustomerId', 'setRegion', 'getRegion', 'getId']);
     $customerModel = $this->getMock('Magento\\Customer\\Model\\Customer', ['getId', 'setId', 'setStoreId', 'getStoreId', 'getAttributeSetId', 'setAttributeSetId', 'setRpToken', 'setRpTokenCreatedAt', 'getDataModel', 'setPasswordHash'], [], '', false);
     $customerAttributesMetaData = $this->getMockForAbstractClass('Magento\\Framework\\Api\\CustomAttributesDataInterface', [], '', false, false, true, ['getId', 'getEmail', 'getWebsiteId', 'getAddresses', 'setAddresses']);
     $this->customer->expects($this->atLeastOnce())->method('getId')->willReturn($customerId);
     $this->customerRegistry->expects($this->atLeastOnce())->method('retrieve')->with($customerId)->willReturn($customerModel);
     $customerModel->expects($this->atLeastOnce())->method('getDataModel')->willReturn($this->customer);
     $this->imageProcessor->expects($this->once())->method('save')->with($this->customer, CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, $this->customer)->willReturn($customerAttributesMetaData);
     $address->expects($this->once())->method('setCustomerId')->with($customerId)->willReturnSelf();
     $address->expects($this->once())->method('getRegion')->willReturn($region);
     $address->expects($this->atLeastOnce())->method('getId')->willReturn(7);
     $address->expects($this->once())->method('setRegion')->with($region);
     $customerAttributesMetaData->expects($this->any())->method('getAddresses')->willReturn([$address]);
     $customerAttributesMetaData->expects($this->at(1))->method('setAddresses')->with([]);
     $customerAttributesMetaData->expects($this->at(2))->method('setAddresses')->with([$address]);
     $this->extensibleDataObjectConverter->expects($this->once())->method('toNestedArray')->with($customerAttributesMetaData, [], '\\Magento\\Customer\\Api\\Data\\CustomerInterface')->willReturn(['customerData']);
     $this->customerFactory->expects($this->once())->method('create')->with(['data' => ['customerData']])->willReturn($customerModel);
     $customerModel->expects($this->once())->method('getStoreId')->willReturn(null);
     $store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
     $store->expects($this->once())->method('getId')->willReturn($storeId);
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($store);
     $customerModel->expects($this->once())->method('setStoreId')->with($storeId);
     $customerModel->expects($this->once())->method('setId')->with(null);
     $customerModel->expects($this->once())->method('getAttributeSetId')->willReturn(null);
     $customerModel->expects($this->once())->method('setAttributeSetId')->with(\Magento\Customer\Api\CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER);
     $customerModel->expects($this->once())->method('setPasswordHash')->with($passwordHash);
     $customerModel->expects($this->atLeastOnce())->method('getId')->willReturn($customerId);
     $this->customerResourceModel->expects($this->once())->method('save')->with($customerModel);
     $this->customerRegistry->expects($this->once())->method('push')->with($customerModel);
     $this->customer->expects($this->any())->method('getAddresses')->willReturn([$address, $address2]);
     $this->addressRepository->expects($this->once())->method('save')->with($address);
     $customerAttributesMetaData->expects($this->once())->method('getEmail')->willReturn('example@example.com');
     $customerAttributesMetaData->expects($this->once())->method('getWebsiteId')->willReturn(2);
     $this->customerRegistry->expects($this->once())->method('retrieveByEmail')->with('example@example.com', 2)->willReturn($customerModel);
     $this->eventManager->expects($this->once())->method('dispatch')->with('customer_save_after_data_object', ['customer_data_object' => $this->customer, 'orig_customer_data_object' => $customerAttributesMetaData]);
     $this->model->save($this->customer, $passwordHash);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:47,代码来源:CustomerRepositoryTest.php


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