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


PHP AddressRepositoryInterface::expects方法代码示例

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


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

示例1: testGetAddressCollectionJson

 public function testGetAddressCollectionJson()
 {
     $addressData = $this->_getAddresses();
     $searchResult = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AddressSearchResultsInterface', [], '', false, true, true, ['getItems']);
     $searchResult->expects($this->any())->method('getItems')->will($this->returnValue($addressData));
     $this->addressRepository->expects($this->any())->method('getList')->will($this->returnValue($searchResult));
     $expectedOutput = '[
         {
             "firstname": false,
             "lastname": false,
             "company": false,
             "street": "",
             "city": false,
             "country_id": "US",
             "region": false,
             "region_id": false,
             "postcode": false,
             "telephone": false,
             "fax": false,
             "vat_id": false
         },
         {
             "firstname": "FirstName1",
             "lastname": "LastName1",
             "company": false,
             "street": "Street1",
             "city": false,
             "country_id": false,
             "region": false,
             "region_id": false,
             "postcode": false,
             "telephone": false,
             "fax": false,
             "vat_id": false
         },
         {
             "firstname": "FirstName2",
             "lastname": "LastName2",
             "company": false,
             "street": "Street2",
             "city": false,
             "country_id": false,
             "region": false,
             "region_id": false,
             "postcode": false,
             "telephone": false,
             "fax": false,
             "vat_id": false
         }
     ]';
     $expectedOutput = str_replace(['    ', "\n", "\r"], '', $expectedOutput);
     $expectedOutput = str_replace(': ', ':', $expectedOutput);
     $this->assertEquals($expectedOutput, $this->_addressBlock->getAddressCollectionJson());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:54,代码来源:AddressTest.php

示例2: testPopulateCustomerInfo

 public function testPopulateCustomerInfo()
 {
     $this->quoteMock->expects($this->once())->method('getCustomer')->willReturn($this->customerMock);
     $this->customerMock->expects($this->atLeastOnce())->method('getId')->willReturn(null);
     $this->customerMock->expects($this->atLeastOnce())->method('getDefaultBilling')->willReturn(100500);
     $this->quoteMock->expects($this->atLeastOnce())->method('getBillingAddress')->willReturn($this->quoteAddressMock);
     $this->quoteMock->expects($this->atLeastOnce())->method('getShippingAddress')->willReturn($this->quoteAddressMock);
     $this->quoteMock->expects($this->atLeastOnce())->method('setCustomer')->with($this->customerMock)->willReturnSelf();
     $this->quoteMock->expects($this->once())->method('getPasswordHash')->willReturn('password hash');
     $this->quoteAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn(null);
     $this->customerAddressRepositoryMock->expects($this->atLeastOnce())->method('getById')->with(100500)->willReturn($this->customerAddressMock);
     $this->quoteAddressMock->expects($this->atLeastOnce())->method('importCustomerAddressData')->willReturnSelf();
     $this->accountManagementMock->expects($this->once())->method('createAccountWithPasswordHash')->with($this->customerMock, 'password hash')->willReturn($this->customerMock);
     $this->customerManagement->populateCustomerInfo($this->quoteMock);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:CustomerManagementTest.php

示例3: testSetLayoutWithoutAddress

 public function testSetLayoutWithoutAddress()
 {
     $addressId = 1;
     $customerPrefix = 'prefix';
     $customerFirstName = 'firstname';
     $customerMiddlename = 'middlename';
     $customerLastname = 'lastname';
     $customerSuffix = 'suffix';
     $title = 'title';
     $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\LayoutInterface')->getMock();
     $this->requestMock->expects($this->once())->method('getParam')->with('id', null)->willReturn($addressId);
     $this->addressRepositoryMock->expects($this->once())->method('getById')->with($addressId)->willThrowException(\Magento\Framework\Exception\NoSuchEntityException::singleField('addressId', $addressId));
     $newAddressMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AddressInterface')->getMock();
     $this->addressDataFactoryMock->expects($this->once())->method('create')->willReturn($newAddressMock);
     $customerMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $this->currentCustomerMock->expects($this->once())->method('getCustomer')->willReturn($customerMock);
     $customerMock->expects($this->once())->method('getPrefix')->willReturn($customerPrefix);
     $customerMock->expects($this->once())->method('getFirstname')->willReturn($customerFirstName);
     $customerMock->expects($this->once())->method('getMiddlename')->willReturn($customerMiddlename);
     $customerMock->expects($this->once())->method('getLastname')->willReturn($customerLastname);
     $customerMock->expects($this->once())->method('getSuffix')->willReturn($customerSuffix);
     $newAddressMock->expects($this->once())->method('setPrefix')->with($customerPrefix)->willReturnSelf();
     $newAddressMock->expects($this->once())->method('setFirstname')->with($customerFirstName)->willReturnSelf();
     $newAddressMock->expects($this->once())->method('setMiddlename')->with($customerMiddlename)->willReturnSelf();
     $newAddressMock->expects($this->once())->method('setLastname')->with($customerLastname)->willReturnSelf();
     $newAddressMock->expects($this->once())->method('setSuffix')->with($customerSuffix)->willReturnSelf();
     $pageTitleMock = $this->getMockBuilder('Magento\\Framework\\View\\Page\\Title')->disableOriginalConstructor()->getMock();
     $this->pageConfigMock->expects($this->once())->method('getTitle')->willReturn($pageTitleMock);
     $this->model->setData('title', $title);
     $pageTitleMock->expects($this->once())->method('set')->with($title)->willReturnSelf();
     $this->assertEquals($this->model, $this->model->setLayout($layoutMock));
     $this->assertEquals($layoutMock, $this->model->getLayout());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:33,代码来源:EditTest.php

示例4: testExecuteWithException

 public function testExecuteWithException()
 {
     $addressId = 1;
     $customerId = 2;
     $this->resultRedirectFactory->expects($this->once())->method('create')->willReturn($this->resultRedirect);
     $this->request->expects($this->once())->method('getParam')->with('id', false)->willReturn($addressId);
     $this->validatorMock->expects($this->once())->method('validate')->with($this->request)->willReturn(true);
     $this->addressRepositoryMock->expects($this->once())->method('getById')->with($addressId)->willReturn($this->address);
     $this->sessionMock->expects($this->once())->method('getCustomerId')->willReturn($customerId);
     $this->address->expects($this->once())->method('getCustomerId')->willReturn(34);
     $exception = new \Exception('Exception');
     $this->messageManager->expects($this->once())->method('addError')->with(__('We can\'t delete the address right now.'))->willThrowException($exception);
     $this->messageManager->expects($this->once())->method('addException')->with($exception, __('We can\'t delete the address right now.'));
     $this->resultRedirect->expects($this->once())->method('setPath')->with('*/*/index')->willReturnSelf();
     $this->assertSame($this->resultRedirect, $this->model->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:DeleteTest.php

示例5: testCreateAccountWithPasswordHashWithCustomerAddresses

 public function testCreateAccountWithPasswordHashWithCustomerAddresses()
 {
     $websiteId = 1;
     $addressId = 2;
     $customerId = null;
     $storeId = 1;
     $hash = '4nj54lkj5jfi03j49f8bgujfgsd';
     //Handle store
     $store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $store->expects($this->any())->method('getWebsiteId')->willReturn($websiteId);
     //Handle address - existing and non-existing. Non-Existing should return null when call getId method
     $existingAddress = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AddressInterface')->disableOriginalConstructor()->getMock();
     $nonExistingAddress = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AddressInterface')->disableOriginalConstructor()->getMock();
     //Ensure that existing address is not in use
     $this->addressRepository->expects($this->atLeastOnce())->method("save")->withConsecutive(array($this->logicalNot($this->identicalTo($existingAddress))), array($this->identicalTo($nonExistingAddress)));
     $existingAddress->expects($this->any())->method("getId")->willReturn($addressId);
     //Expects that id for existing address should be unset
     $existingAddress->expects($this->once())->method("setId")->with(null);
     //Handle Customer calls
     $customer = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $customer->expects($this->atLeastOnce())->method('getWebsiteId')->willReturn($websiteId);
     $customer->expects($this->atLeastOnce())->method('getStoreId')->willReturn($storeId);
     $customer->expects($this->any())->method("getId")->willReturn($customerId);
     //Return Customer from customer repositoryå
     $this->customerRepository->expects($this->atLeastOnce())->method('save')->willReturn($customer);
     $this->customerRepository->expects($this->once())->method('getById')->with($customerId)->willReturn($customer);
     $customerSecure = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\CustomerSecure')->setMethods(['setRpToken', 'setRpTokenCreatedAt', 'getPasswordHash'])->disableOriginalConstructor()->getMock();
     $customerSecure->expects($this->once())->method('setRpToken')->with($hash);
     $customerSecure->expects($this->any())->method('getPasswordHash')->willReturn($hash);
     $this->customerRegistry->expects($this->any())->method('retrieveSecureData')->with($customerId)->willReturn($customerSecure);
     $this->random->expects($this->once())->method('getUniqueHash')->willReturn($hash);
     $customer->expects($this->atLeastOnce())->method('getAddresses')->willReturn([$existingAddress, $nonExistingAddress]);
     $this->storeManager->expects($this->atLeastOnce())->method('getStore')->willReturn($store);
     $this->assertSame($customer, $this->accountManagement->createAccountWithPasswordHash($customer, $hash));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:35,代码来源:AccountManagementTest.php

示例6: testSaveBilling

 /**
  * @dataProvider saveBillingDataProvider
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function testSaveBilling($data, $customerAddressId, $quoteCustomerId, $addressCustomerId, $isAddress, $validateDataResult, $validateResult, $checkoutMethod, $customerPassword, $confirmPassword, $validationResultMessages, $isEmailAvailable, $isVirtual, $getStepDataResult, $expected)
 {
     $useForShipping = (int) $data['use_for_shipping'];
     $passwordHash = 'password hash';
     $this->requestMock->expects($this->any())->method('isAjax')->will($this->returnValue(false));
     $customerValidationResultMock = $this->getMock('Magento\\Customer\\Api\\Data\\ValidationResultsInterface', [], [], '', false);
     $customerValidationResultMock->expects($this->any())->method('isValid')->will($this->returnValue(empty($validationResultMessages)));
     $customerValidationResultMock->expects($this->any())->method('getMessages')->will($this->returnValue($validationResultMessages));
     $this->accountManagementMock->expects($this->any())->method('getPasswordHash')->with($customerPassword)->will($this->returnValue($passwordHash));
     $this->accountManagementMock->expects($this->any())->method('validate')->will($this->returnValue($customerValidationResultMock));
     $this->accountManagementMock->expects($this->any())->method('isEmailAvailable')->will($this->returnValue($isEmailAvailable));
     /** @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject $quoteMock */
     $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', ['getData', 'getCustomerId', '__wakeup', 'getBillingAddress', 'setPasswordHash', 'getCheckoutMethod', 'isVirtual', 'getShippingAddress', 'getCustomerData', 'collectTotals', 'save', 'getCustomer'], [], '', false);
     $customerMock = $this->getMockForAbstractClass('Magento\\Framework\\Api\\AbstractExtensibleObject', [], '', false, true, true, ['__toArray']);
     $shippingAddressMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Address', ['setSameAsBilling', 'save', 'collectTotals', 'addData', 'setShippingMethod', 'setCollectShippingRates', '__wakeup'], [], '', false);
     $quoteMock->expects($this->any())->method('getShippingAddress')->will($this->returnValue($shippingAddressMock));
     $shippingAddressMock->expects($useForShipping ? $this->any() : $this->once())->method('setSameAsBilling')->with($useForShipping)->will($this->returnSelf());
     $expects = !$useForShipping || $checkoutMethod != Onepage::METHOD_REGISTER ? $this->once() : $this->never();
     $shippingAddressMock->expects($expects)->method('save');
     $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never())->method('addData')->will($this->returnSelf());
     $shippingAddressMock->expects($this->any())->method('setSaveInAddressBook')->will($this->returnSelf());
     $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never())->method('setShippingMethod')->will($this->returnSelf());
     $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never())->method('setCollectShippingRates')->will($this->returnSelf());
     $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never())->method('collectTotals');
     $quoteMock->expects($this->any())->method('setPasswordHash')->with($passwordHash);
     $quoteMock->expects($this->any())->method('getCheckoutMethod')->will($this->returnValue($checkoutMethod));
     $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue($isVirtual));
     $addressMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Address', ['setSaveInAddressBook', 'getData', 'setEmail', '__wakeup', 'importCustomerAddressData', 'validate', 'save'], [], '', false);
     $addressMock->expects($this->any())->method('importCustomerAddressData')->will($this->returnSelf());
     $addressMock->expects($this->atLeastOnce())->method('validate')->will($this->returnValue($validateResult));
     $addressMock->expects($this->any())->method('getData')->will($this->returnValue([]));
     $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($addressMock));
     $quoteMock->expects($this->any())->method('getCustomerId')->will($this->returnValue($quoteCustomerId));
     $this->quoteRepositoryMock->expects($checkoutMethod === Onepage::METHOD_REGISTER ? $this->once() : $this->never())->method('save')->with($quoteMock);
     $addressMock->expects($checkoutMethod === Onepage::METHOD_REGISTER ? $this->never() : $this->once())->method('save');
     $quoteMock->expects($this->any())->method('getCustomer')->will($this->returnValue($customerMock));
     $data1 = [];
     $extensibleDataObjectConverterMock = $this->getMock('Magento\\Framework\\Api\\ExtensibleDataObjectConverter', ['toFlatArray'], [], '', false);
     $extensibleDataObjectConverterMock->expects($this->any())->method('toFlatArray')->with($customerMock)->will($this->returnValue($data1));
     $formMock = $this->getMock('Magento\\Customer\\Model\\Metadata\\Form', [], [], '', false);
     $formMock->expects($this->atLeastOnce())->method('validateData')->will($this->returnValue($validateDataResult));
     $this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($formMock));
     $formMock->expects($this->any())->method('prepareRequest')->will($this->returnValue($this->requestMock));
     $formMock->expects($this->any())->method('extractData')->with($this->requestMock)->will($this->returnValue([]));
     $formMock->expects($this->any())->method('validateData')->with([])->will($this->returnValue(false));
     $customerDataMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
     $this->customerDataFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerDataMock));
     $this->checkoutSessionMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock));
     $this->checkoutSessionMock->expects($this->any())->method('getStepData')->will($this->returnValue($useForShipping ? true : $getStepDataResult));
     $this->checkoutSessionMock->expects($this->any())->method('setStepData')->will($this->returnSelf());
     $customerAddressMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AddressInterface', [], '', false);
     $customerAddressMock->expects($this->any())->method('getCustomerId')->will($this->returnValue($addressCustomerId));
     $this->addressRepositoryMock->expects($this->any())->method('getById')->will($isAddress ? $this->returnValue($customerAddressMock) : $this->throwException(new \Exception()));
     $websiteMock = $this->getMock('Magento\\Store\\Model\\Website', [], [], '', false);
     $this->storeManagerMock->expects($this->any())->method('getWebsite')->will($this->returnValue($websiteMock));
     $this->assertEquals($expected, $this->onepage->saveBilling($data, $customerAddressId));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:65,代码来源:OnepageTest.php

示例7: testCreateAccountWithPassword

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testCreateAccountWithPassword()
 {
     $websiteId = 1;
     $storeId = null;
     $defaultStoreId = 1;
     $customerId = 1;
     $customerEmail = 'email@email.com';
     $password = 'wrfewqedf1';
     $hash = '4nj54lkj5jfi03j49f8bgujfgsd';
     $newLinkToken = '2jh43j5h2345jh23lh452h345hfuzasd96ofu';
     $templateIdentifier = 'Template Identifier';
     $sender = 'Sender';
     $this->string->expects($this->any())->method('strlen')->willReturnCallback(function ($string) {
         return strlen($string);
     });
     $this->encryptor->expects($this->once())->method('getHash')->with($password, true)->willReturn($hash);
     $address = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AddressInterface')->disableOriginalConstructor()->getMock();
     $address->expects($this->once())->method('setCustomerId')->with($customerId);
     $store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $store->expects($this->once())->method('getId')->willReturn($defaultStoreId);
     $website = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->getMock();
     $website->expects($this->atLeastOnce())->method('getStoreIds')->willReturn([1, 2, 3]);
     $website->expects($this->once())->method('getDefaultStore')->willReturn($store);
     $customer = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $customer->expects($this->atLeastOnce())->method('getId')->willReturn($customerId);
     $customer->expects($this->atLeastOnce())->method('getEmail')->willReturn($customerEmail);
     $customer->expects($this->atLeastOnce())->method('getWebsiteId')->willReturn($websiteId);
     $customer->expects($this->atLeastOnce())->method('getStoreId')->willReturn($storeId);
     $customer->expects($this->once())->method('setStoreId')->with($defaultStoreId);
     $customer->expects($this->once())->method('getAddresses')->willReturn([$address]);
     $customer->expects($this->once())->method('setAddresses')->with(null);
     $this->customerRepository->expects($this->once())->method('get')->with($customerEmail)->willReturn($customer);
     $this->share->expects($this->once())->method('isWebsiteScope')->willReturn(true);
     $this->storeManager->expects($this->atLeastOnce())->method('getWebsite')->with($websiteId)->willReturn($website);
     $this->customerRepository->expects($this->atLeastOnce())->method('save')->willReturn($customer);
     $this->addressRepository->expects($this->atLeastOnce())->method('save')->with($address);
     $this->customerRepository->expects($this->once())->method('getById')->with($customerId)->willReturn($customer);
     $this->random->expects($this->once())->method('getUniqueHash')->willReturn($newLinkToken);
     $customerSecure = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\CustomerSecure')->setMethods(['setRpToken', 'setRpTokenCreatedAt', 'getPasswordHash'])->disableOriginalConstructor()->getMock();
     $customerSecure->expects($this->any())->method('setRpToken')->with($newLinkToken);
     $customerSecure->expects($this->any())->method('setRpTokenCreatedAt');
     $customerSecure->expects($this->any())->method('getPasswordHash')->willReturn($hash);
     $this->customerRegistry->expects($this->atLeastOnce())->method('retrieveSecureData')->willReturn($customerSecure);
     $this->dataObjectProcessor->expects($this->once())->method('buildOutputDataArray')->willReturn([]);
     $this->scopeConfig->expects($this->at(1))->method('getValue')->with(AccountManagement::XML_PATH_REGISTER_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $defaultStoreId)->willReturn($templateIdentifier);
     $this->scopeConfig->expects($this->at(2))->method('getValue')->willReturn($sender);
     $transport = $this->getMockBuilder('Magento\\Framework\\Mail\\TransportInterface')->getMock();
     $this->transportBuilder->expects($this->once())->method('setTemplateIdentifier')->with($templateIdentifier)->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('setTemplateOptions')->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('setTemplateVars')->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('setFrom')->with($sender)->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('addTo')->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('getTransport')->willReturn($transport);
     $transport->expects($this->once())->method('sendMessage');
     $this->accountManagement->createAccount($customer, $password);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:59,代码来源:AccountManagementTest.php

示例8: testCreateAccountWithPassword

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testCreateAccountWithPassword()
 {
     $websiteId = 1;
     $storeId = null;
     $defaultStoreId = 1;
     $customerId = 1;
     $customerEmail = 'email@email.com';
     $hash = '4nj54lkj5jfi03j49f8bgujfgsd';
     $newLinkToken = '2jh43j5h2345jh23lh452h345hfuzasd96ofu';
     $templateIdentifier = 'Template Identifier';
     $sender = 'Sender';
     $password = 'wrfewqedf1';
     $minPasswordLength = 5;
     $minCharacterSetsNum = 2;
     $this->scopeConfig->expects($this->any())->method('getValue')->willReturnMap([[AccountManagement::XML_PATH_MINIMUM_PASSWORD_LENGTH, 'default', null, $minPasswordLength], [AccountManagement::XML_PATH_REQUIRED_CHARACTER_CLASSES_NUMBER, 'default', null, $minCharacterSetsNum], [AccountManagement::XML_PATH_REGISTER_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $defaultStoreId, $templateIdentifier], [AccountManagement::XML_PATH_REGISTER_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, 1, $sender]]);
     $this->string->expects($this->any())->method('strlen')->with($password)->willReturn(iconv_strlen($password, 'UTF-8'));
     $this->encryptor->expects($this->once())->method('getHash')->with($password, true)->willReturn($hash);
     $address = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AddressInterface')->disableOriginalConstructor()->getMock();
     $address->expects($this->once())->method('setCustomerId')->with($customerId);
     $store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $store->expects($this->once())->method('getId')->willReturn($defaultStoreId);
     $website = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->getMock();
     $website->expects($this->atLeastOnce())->method('getStoreIds')->willReturn([1, 2, 3]);
     $website->expects($this->once())->method('getDefaultStore')->willReturn($store);
     $customer = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $customer->expects($this->atLeastOnce())->method('getId')->willReturn($customerId);
     $customer->expects($this->atLeastOnce())->method('getEmail')->willReturn($customerEmail);
     $customer->expects($this->atLeastOnce())->method('getWebsiteId')->willReturn($websiteId);
     $customer->expects($this->atLeastOnce())->method('getStoreId')->willReturn($storeId);
     $customer->expects($this->once())->method('setStoreId')->with($defaultStoreId);
     $customer->expects($this->once())->method('getAddresses')->willReturn([$address]);
     $customer->expects($this->once())->method('setAddresses')->with(null);
     $this->customerRepository->expects($this->once())->method('get')->with($customerEmail)->willReturn($customer);
     $this->share->expects($this->once())->method('isWebsiteScope')->willReturn(true);
     $this->storeManager->expects($this->atLeastOnce())->method('getWebsite')->with($websiteId)->willReturn($website);
     $this->customerRepository->expects($this->atLeastOnce())->method('save')->willReturn($customer);
     $this->addressRepository->expects($this->atLeastOnce())->method('save')->with($address);
     $this->customerRepository->expects($this->once())->method('getById')->with($customerId)->willReturn($customer);
     $this->random->expects($this->once())->method('getUniqueHash')->willReturn($newLinkToken);
     $customerSecure = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\CustomerSecure')->setMethods(['setRpToken', 'setRpTokenCreatedAt', 'getPasswordHash'])->disableOriginalConstructor()->getMock();
     $customerSecure->expects($this->any())->method('setRpToken')->with($newLinkToken);
     $customerSecure->expects($this->any())->method('setRpTokenCreatedAt');
     $customerSecure->expects($this->any())->method('getPasswordHash')->willReturn($hash);
     $this->customerRegistry->expects($this->atLeastOnce())->method('retrieveSecureData')->willReturn($customerSecure);
     $this->emailNotificationMock->expects($this->once())->method('newAccount')->willReturnSelf();
     $this->accountManagement->createAccount($customer, $password);
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:50,代码来源:AccountManagementTest.php


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