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


PHP Data::expects方法代码示例

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


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

示例1: testGetTransactionUrlTest

 public function testGetTransactionUrlTest()
 {
     $this->prepare();
     $expected = 'https://test.url';
     $methodInstance = $this->getMockBuilder('Magento\\Payment\\Model\\MethodInterface')->getMockForAbstractClass();
     $methodInstance->expects($this->exactly(2))->method('getConfigData')->willReturnMap([['sandbox_flag', null, true], ['cgi_url_test_mode', null, $expected]]);
     $this->paymentDataMock->expects($this->exactly(2))->method('getMethodInstance')->willReturn($methodInstance);
     $block = new \Magento\Paypal\Block\Payflow\Link\Iframe($this->contextMock, $this->orderFactoryMock, $this->checkoutSessionMock, $this->hssHelperMock, $this->paymentDataMock);
     $this->assertEquals($expected, $block->getTransactionUrl());
 }
开发者ID:nja78,项目名称:magento2,代码行数:10,代码来源:IframeTest.php

示例2: testIsMethodQuoteAvailableWithQuoteMethodNotAvailable

 /**
  * @dataProvider methodAvailabilityDataProvider
  * @param bool $availability
  */
 public function testIsMethodQuoteAvailableWithQuoteMethodNotAvailable($availability)
 {
     $quote = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->setMethods([])->getMock();
     $isInCatalog = false;
     $paymentCode = 'code';
     $methodInstanceMock = $this->getMockBuilder('Magento\\Payment\\Model\\Method\\AbstractMethod')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->sessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quote));
     $this->paymentHelperMock->expects($this->once())->method('getMethodInstance')->with($paymentCode)->will($this->returnValue($methodInstanceMock));
     $methodInstanceMock->expects($this->once())->method('isAvailable')->with($quote)->will($this->returnValue($availability));
     $this->assertEquals($availability, $this->checkoutValidator->isMethodQuoteAvailable($paymentCode, $isInCatalog));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:CheckoutValidatorTest.php

示例3: testPrepareDataSource

 public function testPrepareDataSource()
 {
     $itemName = 'itemName';
     $oldItemValue = 'oldItemValue';
     $newItemValue = 'newItemValue';
     $dataSource = ['data' => ['items' => [[$itemName => $oldItemValue]]]];
     $payment = $this->getMockForAbstractClass('Magento\\Payment\\Model\\MethodInterface');
     $payment->expects($this->once())->method('getTitle')->willReturn($newItemValue);
     $this->paymentHelper->expects($this->once())->method('getMethodInstance')->with($oldItemValue)->willReturn($payment);
     $this->model->setData('name', $itemName);
     $this->model->prepareDataSource($dataSource);
     $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
 }
开发者ID:nja78,项目名称:magento2,代码行数:13,代码来源:PaymentMethodTest.php

示例4: testGetConfig

 /**
  * @param int $customerId
  * @param bool $vaultEnabled
  * @dataProvider customerIdProvider
  */
 public function testGetConfig($customerId, $vaultEnabled)
 {
     $storeId = 1;
     $vaultPaymentCode = 'vault_payment';
     $expectedConfiguration = ['vault' => [$vaultPaymentCode => ['is_enabled' => $vaultEnabled]]];
     $this->session->expects(static::once())->method('getCustomerId')->willReturn($customerId);
     $this->storeManager->expects(static::exactly(2))->method('getStore')->willReturn($this->store);
     $this->store->expects(static::exactly(2))->method('getId')->willReturn($storeId);
     $this->paymentDataHelper->expects(static::once())->method('getStoreMethods')->with($storeId)->willReturn([$this->vaultPayment]);
     $this->vaultPayment->expects(static::once())->method('getCode')->willReturn($vaultPaymentCode);
     $this->vaultPayment->expects($customerId !== null ? static::once() : static::never())->method('isActive')->with($storeId)->willReturn($vaultEnabled);
     static::assertEquals($expectedConfiguration, $this->vaultConfigProvider->getConfig());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:18,代码来源:VaultConfigProviderTest.php

示例5: testGetConfigAvailable

 public function testGetConfigAvailable()
 {
     $redirectUrl = 'http://redirect.url';
     $paytypes = ['paytypes'];
     $expectedConfig = ['payment' => ['orbaPayupl' => ['redirectUrl' => $redirectUrl, 'paytypes' => $paytypes]]];
     $paymentMethodMock = $this->getPaymentMethodMock();
     $paymentMethodMock->expects($this->once())->method('isAvailable')->willReturn(true);
     $paymentMethodMock->expects($this->once())->method('getCheckoutRedirectUrl')->willReturn($redirectUrl);
     $this->paymentHelper->expects($this->once())->method('getMethodInstance')->with($this->equalTo('orba_payupl'))->willReturn($paymentMethodMock);
     $quote = $this->getMockBuilder(\Magento\Quote\Api\Data\CartInterface::class)->getMock();
     $this->checkoutSession->expects($this->once())->method('getQuote')->willReturn($quote);
     $this->paytypeHelper->expects($this->once())->method('getAllForQuote')->with($this->equalTo($quote))->willReturn($paytypes);
     $this->assertEquals($expectedConfig, $this->model->getConfig());
 }
开发者ID:tozwierz,项目名称:magento2_payupl,代码行数:14,代码来源:ConfigProviderTest.php

示例6: testToHtmlMethodSetBmlData

 public function testToHtmlMethodSetBmlData()
 {
     $isInCatalog = true;
     $paymentMethodCode = '';
     $bmlMethodCode = '';
     $hash = 'hash';
     $this->shortcut->setIsInCatalogProduct($isInCatalog);
     $expressMethod = $this->getMockBuilder('Magento\\Paypal\\Model\\Express')->disableOriginalConstructor()->setMethods([])->getMock();
     $expectedData = ['is_in_catalog_product' => $isInCatalog, 'shortcut_html_id' => $hash, 'checkout_url' => null, 'image_url' => 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/ppcredit-logo-medium.png', 'additional_link_image' => ['href' => 'https://www.securecheckout.billmelater.com/paycapture-content/' . 'fetch?hash=AU826TU8&content=/bmlweb/ppwpsiw.html', 'src' => 'https://www.paypalobjects.com/webstatic/en_US/btn/btn_bml_text.png']];
     $this->paypalShortcutHelperMock->expects($this->once())->method('validate')->with($paymentMethodCode, $isInCatalog)->will($this->returnValue(true));
     $this->paymentHelperMock->expects($this->once())->method('getMethodInstance')->with($bmlMethodCode)->will($this->returnValue($expressMethod));
     $expressMethod->expects($this->once())->method('isAvailable')->will($this->returnValue(true));
     $this->randomMock->expects($this->once())->method('getUniqueHash')->with('ec_shortcut_bml_')->will($this->returnValue($hash));
     $this->assertEmpty($this->shortcut->toHtml());
     $this->assertContains($expectedData, $this->shortcut->getData());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:ShortcutTest.php

示例7: testGetMethodInstanceRequestedMethod

 public function testGetMethodInstanceRequestedMethod()
 {
     $code = 'real_method';
     $this->info->setData('method', $code);
     $this->paymentHelperMock->expects($this->once())->method('getMethodInstance')->with($code)->willReturn($this->methodInstanceMock);
     $this->methodInstanceMock->expects($this->once())->method('setInfoInstance')->with($this->info);
     $this->assertSame($this->methodInstanceMock, $this->info->getMethodInstance());
     // as the method is already stored at Info, check that it's not initialized again
     $this->assertSame($this->methodInstanceMock, $this->info->getMethodInstance());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:InfoTest.php

示例8: testIsVaultEnabled

 /**
  * @covers \Magento\Braintree\Block\Form::isVaultEnabled
  */
 public function testIsVaultEnabled()
 {
     $storeId = 1;
     $store = $this->getMockForAbstractClass(StoreInterface::class);
     $this->storeManager->expects(static::once())->method('getStore')->willReturn($store);
     $store->expects(static::once())->method('getId')->willReturn($storeId);
     $vaultPayment = $this->getMockForAbstractClass(VaultPaymentInterface::class);
     $this->paymentDataHelper->expects(static::once())->method('getMethodInstance')->with(ConfigProvider::CC_VAULT_CODE)->willReturn($vaultPayment);
     $vaultPayment->expects(static::once())->method('isActive')->with($storeId)->willReturn(true);
     static::assertTrue($this->block->isVaultEnabled());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:FormTest.php

示例9: testGetConfig

 public function testGetConfig()
 {
     $storeId = 1;
     $vaultProviderCode = 'vault_provider_code';
     $expectedConfig = ['payment' => ['vault' => [$vaultProviderCode . '_item_' . '0' => ['config' => ['token_code' => 'code'], 'component' => 'Vendor_Module/js/vault_component']]]];
     $token = $this->getMockForAbstractClass(PaymentTokenInterface::class);
     $tokenUiComponentProvider = $this->getMockForAbstractClass(TokenUiComponentProviderInterface::class);
     $tokenUiComponent = $this->getMockForAbstractClass(TokenUiComponentInterface::class);
     $this->storeManager->expects(static::once())->method('getStore')->willReturn($this->store);
     $this->store->expects(static::once())->method('getId')->willReturn($storeId);
     $this->paymentDataHelper->expects(static::once())->method('getStoreMethods')->with($storeId)->willReturn([$this->vaultPayment]);
     $this->vaultPayment->expects(static::once())->method('isActive')->with($storeId)->willReturn(true);
     $this->vaultPayment->expects(static::once())->method('getProviderCode')->willReturn($vaultProviderCode);
     $this->customerTokenManagement->expects(static::once())->method('getCustomerSessionTokens')->willReturn([$token]);
     $token->expects(static::once())->method('getPaymentMethodCode')->willReturn($vaultProviderCode);
     $tokenUiComponentProvider->expects(static::once())->method('getComponentForToken')->with($token)->willReturn($tokenUiComponent);
     $tokenUiComponent->expects(static::once())->method('getConfig')->willReturn(['token_code' => 'code']);
     $tokenUiComponent->expects(static::once())->method('getName')->willReturn('Vendor_Module/js/vault_component');
     $configProvider = new TokensConfigProvider($this->storeManager, $this->customerTokenManagement, [$vaultProviderCode => $tokenUiComponentProvider]);
     $this->objectManager->setBackwardCompatibleProperty($configProvider, 'paymentDataHelper', $this->paymentDataHelper);
     static::assertEquals($expectedConfig, $configProvider->getConfig());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:22,代码来源:TokensConfigProviderTest.php

示例10: testGetTokensComponentsEmptyComponentProvider

 /**
  * @covers \Magento\Vault\Model\Ui\Adminhtml\TokensConfigProvider::getTokensComponents
  */
 public function testGetTokensComponentsEmptyComponentProvider()
 {
     $storeId = 1;
     $customerId = 2;
     $vaultPaymentCode = 'vault_payment';
     $this->session->expects(static::once())->method('getCustomerId')->willReturn($customerId);
     $this->initStoreMock();
     $this->paymentDataHelper->expects(static::once())->method('getMethodInstance')->with($vaultPaymentCode)->willReturn($this->vaultPayment);
     $this->vaultPayment->expects(static::once())->method('isActive')->with($storeId)->willReturn(false);
     $this->paymentTokenRepository->expects(static::never())->method('getList');
     $configProvider = new TokensConfigProvider($this->session, $this->paymentTokenRepository, $this->filterBuilder, $this->searchCriteriaBuilder, $this->storeManager, $this->dateTimeFactory);
     $this->objectManager->setBackwardCompatibleProperty($configProvider, 'paymentDataHelper', $this->paymentDataHelper);
     static::assertEmpty($configProvider->getTokensComponents($vaultPaymentCode));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:17,代码来源:TokensConfigProviderTest.php


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