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


PHP CustomerInterface::expects方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     if (!function_exists('libxml_set_external_entity_loader')) {
         $this->markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
     }
     $this->customer = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\CustomerInterface', [], '', false, true, true);
     $this->customer->expects($this->once())->method('getWebsiteId')->willReturn(2);
     $this->customerDataFactory = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterfaceFactory', ['create'], [], '', false);
     $this->customerDataFactory->expects($this->once())->method('create')->willReturn($this->customer);
     $this->form = $this->getMock('Magento\\Customer\\Model\\Metadata\\Form', [], [], '', false);
     $this->request = $this->getMockForAbstractClass('Magento\\Framework\\App\\RequestInterface', [], '', false, true, true, ['getPost']);
     $this->response = $this->getMockForAbstractClass('Magento\\Framework\\App\\ResponseInterface', [], '', false);
     $this->formFactory = $this->getMock('Magento\\Customer\\Model\\Metadata\\FormFactory', ['create'], [], '', false);
     $this->formFactory->expects($this->atLeastOnce())->method('create')->willReturn($this->form);
     $this->extensibleDataObjectConverter = $this->getMock('Magento\\Framework\\Api\\ExtensibleDataObjectConverter', [], [], '', false);
     $this->dataObjectHelper = $this->getMock('Magento\\Framework\\Api\\DataObjectHelper', [], [], '', false);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray');
     $this->customerAccountManagement = $this->getMockForAbstractClass('Magento\\Customer\\Api\\AccountManagementInterface', [], '', false, true, true);
     $this->resultJson = $this->getMock('Magento\\Framework\\Controller\\Result\\Json', [], [], '', false);
     $this->resultJson->expects($this->once())->method('setData');
     $this->resultJsonFactory = $this->getMock('Magento\\Framework\\Controller\\Result\\JsonFactory', ['create'], [], '', false);
     $this->resultJsonFactory->expects($this->once())->method('create')->willReturn($this->resultJson);
     $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->controller = $objectHelper->getObject('Magento\\Customer\\Controller\\Adminhtml\\Index\\Validate', ['request' => $this->request, 'response' => $this->response, 'customerDataFactory' => $this->customerDataFactory, 'formFactory' => $this->formFactory, 'extensibleDataObjectConverter' => $this->extensibleDataObjectConverter, 'customerAccountManagement' => $this->customerAccountManagement, 'resultJsonFactory' => $this->resultJsonFactory, 'dataObjectHelper' => $this->dataObjectHelper]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:ValidateTest.php

示例2: testGetCustomerDepersonalizeCustomerData

 /**
  * test getCustomer method, method returns depersonalized customer Data
  */
 public function testGetCustomerDepersonalizeCustomerData()
 {
     $this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(false));
     $this->layoutMock->expects($this->once())->method('isCacheable')->will($this->returnValue(true));
     $this->viewMock->expects($this->once())->method('isLayoutLoaded')->will($this->returnValue(true));
     $this->moduleManagerMock->expects($this->once())->method('isEnabled')->with($this->equalTo('Magento_PageCache'))->will($this->returnValue(true));
     $this->customerSessionMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue($this->customerGroupId));
     $this->customerInterfaceFactoryMock->expects($this->once())->method('create')->will($this->returnValue($this->customerDataMock));
     $this->customerDataMock->expects($this->once())->method('setGroupId')->with($this->equalTo($this->customerGroupId))->will($this->returnSelf());
     $this->assertEquals($this->customerDataMock, $this->currentCustomer->getCustomer());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:CurrentCustomerTest.php

示例3: 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

示例4: testEditPostActionWithoutErrors

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testEditPostActionWithoutErrors()
 {
     $customerId = 24;
     $address = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AddressInterface', [], '', false);
     $loadedCustomer = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\CustomerInterface', [], 'loadedCustomer', false);
     $loadedCustomer->expects($this->once())->method('getAddresses')->willReturn([$address, $address]);
     $this->resultRedirectFactory->expects($this->once())->method('create')->willReturn($this->redirectResultMock);
     $this->formKeyValidator->expects($this->once())->method('validate')->willReturn(true);
     $this->request->expects($this->once())->method('isPost')->willReturn(true);
     $this->customerSession->expects($this->once())->method('getCustomerId')->willReturn($customerId);
     $this->customerExtractor->expects($this->once())->method('extract')->willReturn($this->customer);
     $this->customer->expects($this->once())->method('setId')->with($customerId);
     $this->customer->expects($this->once())->method('getAddresses')->willReturn(null);
     $this->customerRepository->expects($this->exactly(2))->method('getById')->with($customerId)->willReturn($loadedCustomer);
     $this->customer->expects($this->once())->method('setAddresses')->with([$address, $address]);
     $this->request->expects($this->once())->method('getParam')->with('change_password')->willReturn(true);
     $this->request->expects($this->at(2))->method('getPost')->with('current_password', null)->willReturn(123);
     $this->request->expects($this->at(3))->method('getPost')->with('password', null)->willReturn(321);
     $this->request->expects($this->at(4))->method('getPost')->with('password_confirmation', null)->willReturn(321);
     $this->customerAccountManagement->expects($this->once())->method('changePassword');
     $this->customerRepository->expects($this->once())->method('save');
     $messageCollection = $this->getMock('Magento\\Framework\\Message\\Collection', [], [], '', false);
     $messageCollection->expects($this->once())->method('getCount')->willReturn(0);
     $this->messageManager->expects($this->once())->method('getMessages')->willReturn($messageCollection);
     $this->messageManager->expects($this->once())->method('addSuccess')->with('You saved the account information.');
     $this->redirectResultMock->expects($this->once())->method('setPath')->with('customer/account')->willReturn('http://test.com/customer/account/edit');
     $this->assertSame($this->redirectResultMock, $this->getController()->execute());
 }
开发者ID:nja78,项目名称:magento2,代码行数:31,代码来源:EditPostTest.php

示例5: testExtract

 public function testExtract()
 {
     $customerData = ['firstname' => 'firstname', 'lastname' => 'firstname', 'email' => 'email.example.com'];
     $this->formFactory->expects($this->once())->method('create')->with('customer', 'form-code')->willReturn($this->customerForm);
     $this->customerForm->expects($this->once())->method('extractData')->with($this->request)->willReturn($customerData);
     $this->customerForm->expects($this->once())->method('getAllowedAttributes')->willReturn(['group_id' => 'attribute object']);
     $this->customerFactory->expects($this->once())->method('create')->willReturn($this->customerData);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with($this->customerData, $customerData, '\\Magento\\Customer\\Api\\Data\\CustomerInterface')->willReturn($this->customerData);
     $this->storeManager->expects($this->once())->method('getStore')->willReturn($this->store);
     $this->store->expects($this->exactly(2))->method('getId')->willReturn(1);
     $this->customerGroupManagement->expects($this->once())->method('getDefaultGroup')->with(1)->willReturn($this->customerGroup);
     $this->customerGroup->expects($this->once())->method('getId')->willReturn(1);
     $this->customerData->expects($this->once())->method('setGroupId')->with(1);
     $this->store->expects($this->once())->method('getWebsiteId')->willReturn(1);
     $this->customerData->expects($this->once())->method('setWebsiteId')->with(1);
     $this->customerData->expects($this->once())->method('setStoreId')->with(1);
     $this->assertSame($this->customerData, $this->customerExtractor->extract('form-code', $this->request));
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:18,代码来源:CustomerExtractorTest.php

示例6: testDelete

 public function testDelete()
 {
     $customerId = 14;
     $customerModel = $this->getMock('Magento\\Customer\\Model\\Customer', ['delete'], [], '', false);
     $this->customer->expects($this->once())->method('getId')->willReturn($customerId);
     $this->customerRegistry->expects($this->once())->method('retrieve')->with($customerId)->willReturn($customerModel);
     $customerModel->expects($this->once())->method('delete');
     $this->customerRegistry->expects($this->once())->method('remove')->with($customerId);
     $this->assertTrue($this->model->delete($this->customer));
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:10,代码来源:CustomerRepositoryTest.php

示例7: testExecuteException

 public function testExecuteException()
 {
     $exception = new \Exception('Exception message');
     $this->prepareMocksForTesting();
     $this->customerData->expects($this->once())->method('getDefaultBilling')->willReturn(false);
     $this->customerRepository->expects($this->once())->method('save')->with($this->customerData)->willThrowException($exception);
     $this->messageManager->expects($this->once())->method('addError')->with('[Customer ID: 12] We can\'t save the customer.');
     $this->logger->expects($this->once())->method('critical')->with($exception);
     $this->prepareMocksForErrorMessagesProcessing();
     $this->assertSame($this->resultJson, $this->controller->execute());
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:11,代码来源:InlineEditTest.php

示例8: testSuccessRedirect

 /**
  * @param $customerId
  * @param $key
  * @param $backUrl
  * @param $successUrl
  * @param $resultUrl
  * @param $isSetFlag
  * @param $successMessage
  *
  * @dataProvider getSuccessRedirectDataProvider
  */
 public function testSuccessRedirect($customerId, $key, $backUrl, $successUrl, $resultUrl, $isSetFlag, $successMessage)
 {
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
     $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['id', false, $customerId], ['key', false, $key], ['back_url', false, $backUrl]]);
     $this->customerRepositoryMock->expects($this->any())->method('getById')->with($customerId)->will($this->returnValue($this->customerDataMock));
     $email = 'test@example.com';
     $this->customerDataMock->expects($this->once())->method('getEmail')->will($this->returnValue($email));
     $this->customerAccountManagementMock->expects($this->once())->method('activate')->with($this->equalTo($email), $this->equalTo($key))->will($this->returnValue($this->customerDataMock));
     $this->customerSessionMock->expects($this->any())->method('setCustomerDataAsLoggedIn')->with($this->equalTo($this->customerDataMock))->willReturnSelf();
     $this->messageManagerMock->expects($this->any())->method('addSuccess')->with($this->stringContains($successMessage))->willReturnSelf();
     $this->storeMock->expects($this->any())->method('getFrontendName')->will($this->returnValue('frontend'));
     $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock));
     $this->urlMock->expects($this->any())->method('getUrl')->with($this->equalTo('*/*/index'), ['_secure' => true])->will($this->returnValue($successUrl));
     $this->redirectMock->expects($this->never())->method('success')->with($this->equalTo($resultUrl))->willReturn($resultUrl);
     $this->scopeConfigMock->expects($this->never())->method('isSetFlag')->with(Url::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD, ScopeInterface::SCOPE_STORE)->willReturn($isSetFlag);
     $this->model->execute();
 }
开发者ID:kid17,项目名称:magento2,代码行数:28,代码来源:ConfirmTest.php

示例9: testSuccessRedirect

 /**
  * @param $customerId
  * @param $password
  * @param $confirmationStatus
  * @param $successUrl
  * @param $isSetFlag
  * @param $successMessage
  *
  * @dataProvider getSuccessRedirectDataProvider
  */
 public function testSuccessRedirect($customerId, $password, $confirmationStatus, $successUrl, $isSetFlag, $successMessage)
 {
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
     $this->registration->expects($this->once())->method('isAllowed')->will($this->returnValue(true));
     $this->customerSessionMock->expects($this->once())->method('regenerateId');
     $this->customerMock->expects($this->any())->method('getId')->will($this->returnValue($customerId));
     $this->customerExtractorMock->expects($this->any())->method('extract')->with($this->equalTo('customer_account_create'), $this->equalTo($this->requestMock))->will($this->returnValue($this->customerMock));
     $this->requestMock->expects($this->once())->method('isPost')->will($this->returnValue(true));
     $this->requestMock->expects($this->any())->method('getPost')->will($this->returnValue(false));
     $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['password', null, $password], ['password_confirmation', null, $password], ['is_subscribed', false, true]]);
     $this->customerMock->expects($this->once())->method('setAddresses')->with($this->equalTo([]))->will($this->returnSelf());
     $this->accountManagement->expects($this->once())->method('createAccount')->with($this->equalTo($this->customerDetailsMock), $this->equalTo($password), '')->will($this->returnValue($this->customerMock));
     $this->accountManagement->expects($this->once())->method('getConfirmationStatus')->with($this->equalTo($customerId))->will($this->returnValue($confirmationStatus));
     $this->subscriberMock->expects($this->once())->method('subscribeCustomerById')->with($this->equalTo($customerId));
     $this->messageManagerMock->expects($this->any())->method('addSuccess')->with($this->stringContains($successMessage))->will($this->returnSelf());
     $this->urlMock->expects($this->any())->method('getUrl')->willReturnMap([['*/*/index', ['_secure' => true], $successUrl], ['*/*/create', ['_secure' => true], $successUrl]]);
     $this->redirectMock->expects($this->once())->method('success')->with($this->equalTo($successUrl))->will($this->returnValue($successUrl));
     $this->scopeConfigMock->expects($this->once())->method('isSetFlag')->with($this->equalTo(Url::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD), $this->equalTo(ScopeInterface::SCOPE_STORE))->will($this->returnValue($isSetFlag));
     $this->storeMock->expects($this->any())->method('getFrontendName')->will($this->returnValue('frontend'));
     $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock));
     $this->model->execute();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:32,代码来源:CreatePostTest.php


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