本文整理汇总了PHP中Magento\Customer\Model\Customer::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Customer::expects方法的具体用法?PHP Customer::expects怎么用?PHP Customer::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Customer\Model\Customer
的用法示例。
在下文中一共展示了Customer::expects方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetButtonData
/**
* @param array $result
* @param bool $expectedValue
* @dataProvider getButtonDataProvider
*/
public function testGetButtonData($result, $expectedValue)
{
$this->registryMock->expects($this->any())->method('registry')->willReturn(1);
$this->customerRegistryMock->expects($this->once())->method('retrieve')->willReturn($this->customerModelMock);
$this->customerModelMock->expects($this->once())->method('isCustomerLocked')->willReturn($expectedValue);
$this->urlBuilderMock->expects($this->any())->method('getUrl')->willReturn('http://website.com/');
$this->assertEquals($result, $this->block->getButtonData());
}
示例2: testExecute
/**
* @return void
*/
public function testExecute()
{
$customerId = 1;
$observerMock = $this->getMock('Magento\\Framework\\Event\\Observer', [], [], '', false);
$eventMock = $this->getMock('Magento\\Framework\\Event', ['getData'], [], '', false);
$observerMock->expects($this->once())->method('getEvent')->willReturn($eventMock);
$eventMock->expects($this->once())->method('getData')->with('model')->willReturn($this->customerModelMock);
$this->customerModelMock->expects($this->once())->method('getId')->willReturn($customerId);
$this->authenticationMock->expects($this->once())->method('unlock')->with($customerId);
$this->customerLoginSuccessObserver->execute($observerMock);
}
示例3: testExecute
/**
* @return void
*/
public function testExecute()
{
$customerId = 1;
$observerMock = $this->getMock('Magento\\Framework\\Event\\Observer', [], [], '', false);
$eventMock = $this->getMock('Magento\\Framework\\Event', ['getData'], [], '', false);
$observerMock->expects($this->once())->method('getEvent')->willReturn($eventMock);
$eventMock->expects($this->once())->method('getData')->with('model')->willReturn($this->customerModelMock);
$this->customerModelMock->expects($this->once())->method('getId')->willReturn($customerId);
$this->customerRepositoryMock->expects($this->once())->method('getById')->willReturn($this->customerDataMock);
$this->customerDataMock->expects($this->once())->method('getId')->willReturn($customerId);
$this->accountManagementHelperMock->expects($this->once())->method('processUnlockData')->with($customerId);
$this->customerRepositoryMock->expects($this->once())->method('save')->with($this->customerDataMock);
$this->customerLoginSuccessObserver->execute($observerMock);
}
示例4: testGetAccountLock
/**
* @param string $expectedResult
* @param bool $value
* @dataProvider getAccountLockDataProvider
* @return void
*/
public function testGetAccountLock($expectedResult, $value)
{
$this->customerRegistry->expects($this->once())->method('retrieve')->willReturn($this->customerModel);
$this->customerModel->expects($this->once())->method('isCustomerLocked')->willReturn($value);
$expectedResult = new \Magento\Framework\Phrase($expectedResult);
$this->assertEquals($expectedResult, $this->block->getAccountLock());
}
示例5: testValidateResetPasswordToken
/**
* return bool
*/
public function testValidateResetPasswordToken()
{
$this->reInitModel();
$this->customer->expects($this->once())->method('getResetPasswordLinkExpirationPeriod')->willReturn(100000);
$this->customerRegistry->expects($this->atLeastOnce())->method('retrieveSecureData')->willReturn($this->customerSecure);
$this->assertTrue($this->accountManagement->validateResetPasswordLinkToken(22, 'newStringToken'));
}
示例6: testDeleteById
public function testDeleteById()
{
$addressId = 12;
$customerId = 43;
$this->address->expects($this->once())->method('getCustomerId')->willReturn($customerId);
$addressCollection = $this->getMock('Magento\\Customer\\Model\\ResourceModel\\Address\\Collection', [], [], '', false);
$this->addressRegistry->expects($this->once())->method('retrieve')->with($addressId)->willReturn($this->address);
$this->customerRegistry->expects($this->once())->method('retrieve')->with($customerId)->willReturn($this->customer);
$this->customer->expects($this->once())->method('getAddressesCollection')->willReturn($addressCollection);
$addressCollection->expects($this->once())->method('clear');
$this->addressResourceModel->expects($this->once())->method('delete')->with($this->address);
$this->addressRegistry->expects($this->once())->method('remove')->with($addressId);
$this->assertTrue($this->repository->deleteById($addressId));
}
示例7: testRemoveByEmail
public function testRemoveByEmail()
{
$this->customer->expects($this->exactly(2))->method('loadByEmail')->with(self::CUSTOMER_EMAIL)->will($this->returnValue($this->customer));
$this->customer->expects($this->any())->method('getId')->will($this->returnValue(self::CUSTOMER_ID));
$this->customer->expects($this->any())->method('getEmail')->will($this->returnValue(self::CUSTOMER_EMAIL));
$this->customer->expects($this->any())->method('getWebsiteId')->will($this->returnValue(self::WEBSITE_ID));
$this->customer->expects($this->any())->method('setEmail')->will($this->returnValue($this->customer));
$this->customer->expects($this->any())->method('setWebsiteId')->will($this->returnValue($this->customer));
$this->customerFactory->expects($this->exactly(2))->method('create')->will($this->returnValue($this->customer));
$actual = $this->customerRegistry->retrieveByEmail(self::CUSTOMER_EMAIL, self::WEBSITE_ID);
$this->assertEquals($this->customer, $actual);
$this->customerRegistry->removeByEmail(self::CUSTOMER_EMAIL, self::WEBSITE_ID);
$actual = $this->customerRegistry->retrieveByEmail(self::CUSTOMER_EMAIL, self::WEBSITE_ID);
$this->assertEquals($this->customer, $actual);
}
示例8: testAfterGenerateXmlNoDepersonalize
public function testAfterGenerateXmlNoDepersonalize()
{
$expectedResult = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false);
$this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(false);
$this->visitorMock->expects($this->never())->method('setSkipRequestLogging');
$this->visitorMock->expects($this->never())->method('unsetData');
$this->sessionMock->expects($this->never())->method('clearStorage');
$this->customerSessionMock->expects($this->never())->method('clearStorage');
$this->customerSessionMock->expects($this->never())->method('setCustomerGroupId');
$this->customerMock->expects($this->never())->method('setGroupId');
$this->sessionMock->expects($this->never())->method('setData');
$this->customerSessionMock->expects($this->never())->method('setCustomer');
$actualResult = $this->plugin->afterGenerateXml($this->layoutMock, $expectedResult);
$this->assertSame($expectedResult, $actualResult);
}
示例9: testAfterGenerateXmlPageCacheEnabled
/**
* Test method afterGenerateXml with enabled module PageCache
*/
public function testAfterGenerateXmlPageCacheEnabled()
{
$expectedResult = $this->getMock('Magento\\Framework\\View\\Layout', array(), array(), '', false);
$this->moduleManagerMock->expects($this->once())->method('isEnabled')->with('Magento_PageCache')->will($this->returnValue(true));
$this->cacheConfigMock->expects($this->once())->method('isEnabled')->will($this->returnValue(true));
$this->requestMock->expects($this->once())->method('isAjax')->will($this->returnValue(false));
$this->layoutMock->expects($this->once())->method('isCacheable')->will($this->returnValue(true));
$this->visitorMock->expects($this->once())->method('setSkipRequestLogging')->with($this->equalTo(true));
$this->visitorMock->expects($this->once())->method('unsetData');
$this->sessionMock->expects($this->once())->method('clearStorage');
$this->customerSessionMock->expects($this->once())->method('clearStorage');
$this->customerSessionMock->expects($this->once())->method('setCustomerGroupId')->with($this->equalTo(null));
$this->customerMock->expects($this->once())->method('setGroupId')->with($this->equalTo(null));
$this->sessionMock->expects($this->once())->method('setData')->with($this->equalTo(\Magento\Framework\Data\Form\FormKey::FORM_KEY), $this->equalTo(null));
$this->customerSessionMock->expects($this->once())->method('setCustomer')->with($this->equalTo($this->customerMock));
$actualResult = $this->plugin->afterGenerateXml($this->layoutMock, $expectedResult);
$this->assertSame($expectedResult, $actualResult);
}
示例10: testProcessNonceException
/**
* @param string $params
* @dataProvider dataProcessNonce
*/
public function testProcessNonceException($params = null, $exceptionMessage = null)
{
$this->customerSessionMock->expects($this->any())->method('getCustomerId')->willReturn($params['customerId']);
$countryCollectionMock = $this->getMockBuilder('\\Magento\\Directory\\Model\\Resource\\Country\\Collection')->disableOriginalConstructor()->getMock();
$countryCollectionMock->expects($this->any())->method('addCountryCodeFilter')->willReturn($countryCollectionMock);
$this->countryFactoryMock->expects($this->any())->method('create')->willReturn($countryCollectionMock);
$this->configMock->expects($this->any())->method('canUseForCountry')->willReturn($params['canUseForCountry']);
$this->configMock->expects($this->any())->method('canUseCcTypeForCountry')->willReturn($params['canUseCcTypeForCountry']);
$this->helperMock->expects($this->any())->method('generateCustomerId')->willReturn($params['customerId']);
$this->customerMock->expects($this->any())->method('load')->willReturn($this->customerMock);
$this->customerFactoryMock->expects($this->any())->method('create')->willReturn($this->customerMock);
if (is_object($params['paymentMethodObj'])) {
if (!$params['optionsArray']['update']) {
$this->braintreePaymentMethodMock->expects($this->once())->method('create')->willReturn($params['paymentMethodObj']);
} else {
$this->braintreePaymentMethodMock->expects($this->once())->method('update')->willReturn($params['paymentMethodObj']);
}
if (!$params['paymentMethodObj']->success) {
$this->errorHelperMock->expects($this->once())->method('parseBraintreeError')->willReturn(new \Magento\Framework\Phrase($exceptionMessage));
} else {
$this->errorHelperMock->expects($this->never())->method('parseBraintreeError');
}
}
try {
$this->model->processNonce($params['nonce'], $params['optionsArray'], $params['billingAddress']);
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->assertEquals($exceptionMessage, $e->getMessage());
}
}