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


PHP ScopeConfigInterface::expects方法代码示例

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


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

示例1: testAddInStockFilterToCollection

 /**
  * @dataProvider filterProvider
  */
 public function testAddInStockFilterToCollection($configMock)
 {
     $collectionMock = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Product\\Link\\Product\\Collection')->disableOriginalConstructor()->getMock();
     $collectionMock->expects($this->any())->method('joinField');
     $this->scopeConfigMock->expects($this->any())->method('getValue')->willReturn($configMock);
     $this->assertNull($this->stock->addInStockFilterToCollection($collectionMock));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:StockTest.php

示例2: testShouldBeSecure

 /**
  * @param $unsecureBaseUrl
  * @param $useSecureInAdmin
  * @param $secureBaseUrl
  * @param $expected
  * @dataProvider shouldBeSecureDataProvider
  */
 public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureBaseUrl, $expected)
 {
     $coreConfigValueMap = [[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, 'default', null, $unsecureBaseUrl], [\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, 'default', null, $secureBaseUrl]];
     $this->coreConfig->expects($this->any())->method('getValue')->will($this->returnValueMap($coreConfigValueMap));
     $this->backendConfig->expects($this->any())->method('isSetFlag')->willReturn($useSecureInAdmin);
     $this->assertEquals($expected, $this->adminPathConfig->shouldBeSecure(''));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:AdminPathConfigTest.php

示例3: testGetLinksTitleWithoutTitle

 public function testGetLinksTitleWithoutTitle()
 {
     $product = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['_wakeup', 'getLinksTitle'])->getMock();
     $product->expects($this->once())->method('getLinksTitle')->willReturn(null);
     $this->scopeConfig->expects($this->once())->method('getValue')->with(\Magento\Downloadable\Model\Link::XML_PATH_LINKS_TITLE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->willReturn('scope_config_value');
     $this->assertEquals('scope_config_value', $this->helper->getLinksTitle($product));
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:7,代码来源:ConfigurationTest.php

示例4: testIsHostBackend

 /**
  * @param $url
  * @param $host
  * @dataProvider hostsDataProvider
  */
 public function testIsHostBackend($url, $host, $expectedValue)
 {
     $backendUrl = $url;
     $_SERVER['HTTP_HOST'] = $host;
     $this->scopeConfigMock->expects($this->once())->method('getValue')->with(Store::XML_PATH_UNSECURE_BASE_URL, ScopeInterface::SCOPE_STORE)->willReturn($backendUrl);
     $this->assertEquals($this->model->isHostBackend(), $expectedValue);
 }
开发者ID:nghongson,项目名称:magento2,代码行数:12,代码来源:FrontNameResolverTest.php

示例5: testAfterDelete

 public function testAfterDelete()
 {
     $this->configMock->expects($this->any())->method('getValue')->willReturnMap([[Theme::XML_PATH_INVALID_CACHES, ScopeInterface::SCOPE_STORE, null, ['block_html' => 1, 'layout' => 1, 'translate' => 1]], [null, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, 'old_value']]);
     $this->cacheTypeListMock->expects($this->exactly(2))->method('invalidate');
     $this->model->setValue('some_value');
     $this->assertSame($this->model, $this->model->afterDelete());
 }
开发者ID:rafaelstz,项目名称:magento2,代码行数:7,代码来源:ThemeTest.php

示例6: testSubscribe

 public function testSubscribe()
 {
     $email = 'subscriber_email@magento.com';
     $this->resource->expects($this->any())->method('loadByEmail')->willReturn(['subscriber_status' => 3, 'subscriber_email' => $email, 'name' => 'subscriber_name']);
     $this->resource->expects($this->any())->method('getIdFieldName')->willReturn('id_field');
     $this->scopeConfig->expects($this->any())->method('getValue')->willReturn(true);
     $this->customerSession->expects($this->any())->method('isLoggedIn')->willReturn(true);
     $customerDataModel = $this->getMock('\\Magento\\Customer\\Api\\Data\\CustomerInterface');
     $this->customerSession->expects($this->any())->method('getCustomerDataObject')->willReturn($customerDataModel);
     $this->customerSession->expects($this->any())->method('getCustomerId')->willReturn(1);
     $customerDataModel->expects($this->any())->method('getEmail')->willReturn($email);
     $this->customerRepository->expects($this->any())->method('getById')->willReturn($customerDataModel);
     $customerDataModel->expects($this->any())->method('getStoreId')->willReturn(1);
     $customerDataModel->expects($this->any())->method('getId')->willReturn(1);
     $this->transportBuilder->expects($this->any())->method('setTemplateIdentifier')->willReturnSelf();
     $this->transportBuilder->expects($this->any())->method('setTemplateOptions')->willReturnSelf();
     $this->transportBuilder->expects($this->any())->method('setTemplateVars')->willReturnSelf();
     $this->transportBuilder->expects($this->any())->method('setFrom')->willReturnSelf();
     $this->transportBuilder->expects($this->any())->method('addTo')->willReturnSelf();
     $storeModel = $this->getMock('\\Magento\\Store\\Model\\Store', ['getId'], [], '', false);
     $this->scopeConfig->expects($this->any())->method('getValue')->willReturn('owner_email@magento.com');
     $this->storeManager->expects($this->any())->method('getStore')->willReturn($storeModel);
     $storeModel->expects($this->any())->method('getId')->willReturn(1);
     $transport = $this->getMock('\\Magento\\Framework\\Mail\\TransportInterface');
     $this->transportBuilder->expects($this->any())->method('getTransport')->willReturn($transport);
     $transport->expects($this->any())->method('sendMessage')->willReturnSelf();
     $inlineTranslation = $this->getMock('Magento\\Framework\\Translate\\Inline\\StateInterface');
     $inlineTranslation->expects($this->any())->method('resume')->willReturnSelf();
     $this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf();
     $this->assertEquals(1, $this->subscriber->subscribe($email));
 }
开发者ID:opexsw,项目名称:magento2,代码行数:31,代码来源:SubscriberTest.php

示例7: testAuthorize

 public function testAuthorize()
 {
     $paymentAction = 'some_action';
     $this->scopeConfigMock->expects($this->any())->method('getValue')->with('payment/paymentmethod_directpost/payment_action', 'store', null)->willReturn($paymentAction);
     $this->paymentMock->expects($this->once())->method('setAdditionalInformation')->with('payment_type', $paymentAction);
     $this->directpost->authorize($this->paymentMock, 10);
 }
开发者ID:steegi,项目名称:paystand-magento2,代码行数:7,代码来源:DirectpostTest.php

示例8: testExecute

 /**
  * @return void
  */
 public function testExecute()
 {
     $customerId = 7;
     $captchaValue = 'some-value';
     $email = 'test@example.com';
     $redirectUrl = 'http://magento.com/customer/account/edit/';
     $captcha = $this->getMock('Magento\\Captcha\\Model\\DefaultModel', [], [], '', false);
     $captcha->expects($this->once())->method('isRequired')->willReturn(true);
     $captcha->expects($this->once())->method('isCorrect')->with($captchaValue)->willReturn(false);
     $this->helperMock->expects($this->once())->method('getCaptcha')->with(\Magento\Captcha\Observer\CheckUserEditObserver::FORM_ID)->willReturn($captcha);
     $response = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false);
     $request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $request->expects($this->any())->method('getPost')->with(\Magento\Captcha\Helper\Data::INPUT_NAME_FIELD_VALUE, null)->willReturn([\Magento\Captcha\Observer\CheckUserEditObserver::FORM_ID => $captchaValue]);
     $controller = $this->getMock('Magento\\Framework\\App\\Action\\Action', [], [], '', false);
     $controller->expects($this->any())->method('getRequest')->will($this->returnValue($request));
     $controller->expects($this->any())->method('getResponse')->will($this->returnValue($response));
     $this->captchaStringResolverMock->expects($this->once())->method('resolve')->with($request, \Magento\Captcha\Observer\CheckUserEditObserver::FORM_ID)->willReturn($captchaValue);
     $customerDataMock = $this->getMock('\\Magento\\Customer\\Model\\Data\\Customer', [], [], '', false);
     $this->customerSessionMock->expects($this->once())->method('getCustomerId')->willReturn($customerId);
     $this->customerSessionMock->expects($this->atLeastOnce())->method('getCustomer')->willReturn($customerDataMock);
     $this->authenticationMock->expects($this->once())->method('processAuthenticationFailure')->with($customerId);
     $this->authenticationMock->expects($this->once())->method('isLocked')->with($customerId)->willReturn(true);
     $this->customerSessionMock->expects($this->once())->method('logout');
     $this->customerSessionMock->expects($this->once())->method('start');
     $this->scopeConfigMock->expects($this->once())->method('getValue')->with('contact/email/recipient_email')->willReturn($email);
     $message = __('The account is locked. Please wait and try again or contact %1.', $email);
     $this->messageManagerMock->expects($this->exactly(2))->method('addError')->withConsecutive([$message], [__('Incorrect CAPTCHA')]);
     $this->actionFlagMock->expects($this->once())->method('set')->with('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
     $this->redirectMock->expects($this->once())->method('redirect')->with($response, '*/*/edit')->willReturn($redirectUrl);
     $this->observer->execute(new \Magento\Framework\Event\Observer(['controller_action' => $controller]));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:34,代码来源:CheckUserEditObserverTest.php

示例9: testAfterSave

 /**
  * @param int $callNumber
  * @param string $oldValue
  * @dataProvider afterSaveDataProvider
  */
 public function testAfterSave($callNumber, $oldValue)
 {
     $this->cacheTypeListMock->expects($this->exactly($callNumber))->method('invalidate');
     $this->configMock->expects($this->any())->method('getValue')->willReturnMap([[Theme::XML_PATH_INVALID_CACHES, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null, ['block_html' => 1, 'layout' => 1, 'translate' => 1]], [null, \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, $oldValue]]);
     $this->model->setValue('some_value');
     $this->assertInstanceOf(get_class($this->model), $this->model->afterSave());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:ThemeTest.php

示例10: testAddTrackingNumbersToShipment

 /**
  * @covers \Magento\Shipping\Model\Shipping\LabelGenerator
  * @param array $info
  * @dataProvider labelInfoDataProvider
  */
 public function testAddTrackingNumbersToShipment(array $info)
 {
     $order = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $order->expects(static::once())->method('getShippingMethod')->with(true)->willReturn($this->getShippingMethodMock());
     /**
      * @var $shipmentMock \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject
      */
     $shipmentMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Shipment')->disableOriginalConstructor()->getMock();
     $shipmentMock->expects(static::once())->method('getOrder')->willReturn($order);
     $this->carrierFactory->expects(static::once())->method('create')->with(self::CARRIER_CODE)->willReturn($this->getCarrierMock());
     $labelsMock = $this->getMockBuilder('\\Magento\\Shipping\\Model\\Shipping\\Labels')->disableOriginalConstructor()->getMock();
     $labelsMock->expects(static::once())->method('requestToShipment')->with($shipmentMock)->willReturn($this->getResponseMock($info));
     $this->labelsFactory->expects(static::once())->method('create')->willReturn($labelsMock);
     $this->filesystem->expects(static::once())->method('getDirectoryWrite')->willReturn($this->getMock('Magento\\Framework\\Filesystem\\Directory\\WriteInterface'));
     $this->scopeConfig->expects(static::once())->method('getValue')->with('carriers/' . self::CARRIER_CODE . '/title', ScopeInterface::SCOPE_STORE, null)->willReturn(self::CARRIER_TITLE);
     $this->labelsFactory->expects(static::once())->method('create')->willReturn($labelsMock);
     $trackMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Shipment\\Track')->setMethods(['setNumber', 'setCarrierCode', 'setTitle'])->disableOriginalConstructor()->getMock();
     $i = 0;
     $trackingNumbers = is_array($info['tracking_number']) ? $info['tracking_number'] : [$info['tracking_number']];
     foreach ($trackingNumbers as $trackingNumber) {
         $trackMock->expects(static::at($i++))->method('setNumber')->with($trackingNumber)->willReturnSelf();
         $trackMock->expects(static::at($i++))->method('setCarrierCode')->with(self::CARRIER_CODE)->willReturnSelf();
         $trackMock->expects(static::at($i++))->method('setTitle')->with(self::CARRIER_TITLE)->willReturnSelf();
     }
     $this->trackFactory->expects(static::any())->method('create')->willReturn($trackMock);
     /**
      * @var $requestMock \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
      */
     $requestMock = $this->getMock('Magento\\Framework\\App\\RequestInterface');
     $this->labelGenerator->create($shipmentMock, $requestMock);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:36,代码来源:LabelGeneratorTest.php

示例11: testIsBillingAddressEnabled

 public function testIsBillingAddressEnabled()
 {
     $isEnabled = 1;
     $prefix = 'payment/braintree_paypal/';
     $this->scopeConfigMock->expects($this->once())->method('getValue')->with($prefix . PayPal::KEY_REQUIRE_BILLING_ADDRESS, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null)->willReturn($isEnabled);
     $this->assertEquals(true, $this->model->isBillingAddressEnabled());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:7,代码来源:PayPalTest.php

示例12: testAfterGetStateActive

 /**
  * @dataProvider afterGetStateActiveDataProvider
  */
 public function testAfterGetStateActive($scopeConfigMockReturnValue, $result, $assertResult)
 {
     /** @var \Magento\Checkout\Block\Cart\Shipping $subjectMock */
     $subjectMock = $this->getMockBuilder('Magento\\Checkout\\Block\\Cart\\Shipping')->disableOriginalConstructor()->getMock();
     $this->scopeConfigMock->expects($result ? $this->never() : $this->once())->method('getValue')->willReturn($scopeConfigMockReturnValue);
     $this->assertEquals($assertResult, $this->model->afterGetStateActive($subjectMock, $result));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:ShippingTest.php

示例13: testProcessAlternativeSource

 /**
  * Run test for process method
  */
 public function testProcessAlternativeSource()
 {
     $chainMock = $this->getChainMock();
     $this->scopeConfigMock->expects(self::once())->method('getValue')->with(WorkflowType::CONFIG_NAME_PATH)->willReturn('off');
     $this->alternativeSourceMock->expects(self::once())->method('process')->with($chainMock);
     $this->frontendCompilationMock->expects(self::never())->method('process');
     $this->preprocessorStrategy->process($chainMock);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:11,代码来源:PreprocessorStrategyTest.php

示例14: testGet

 public function testGet()
 {
     $expectedResult = ['interval_division_limit' => 15, 'range_step' => 3.3, 'min_range_power' => 10, 'max_intervals_number' => 33];
     $this->scopeConfig->expects($this->at(0))->method('getValue')->withConsecutive([Options::XML_PATH_INTERVAL_DIVISION_LIMIT, ScopeInterface::SCOPE_STORE])->willReturn($expectedResult['interval_division_limit']);
     $this->scopeConfig->expects($this->at(1))->method('getValue')->withConsecutive([Options::XML_PATH_RANGE_STEP, ScopeInterface::SCOPE_STORE])->willReturn($expectedResult['range_step']);
     $this->scopeConfig->expects($this->at(2))->method('getValue')->withConsecutive([Options::XML_PATH_RANGE_MAX_INTERVALS, ScopeInterface::SCOPE_STORE])->willReturn($expectedResult['max_intervals_number']);
     $this->options->get();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:8,代码来源:OptionsTest.php

示例15: testGetThemeByRequest

 /**
  * @param string $userAgent
  * @param bool $useConfig
  * @param bool|string $result
  * @param array $expressions
  * @dataProvider getThemeByRequestDataProvider
  */
 public function testGetThemeByRequest($userAgent, $useConfig, $result, $expressions = [])
 {
     $this->requestMock->expects($this->once())->method('getServer')->with($this->equalTo('HTTP_USER_AGENT'))->will($this->returnValue($userAgent));
     if ($useConfig) {
         $this->scopeConfigMock->expects($this->once())->method('getValue')->with($this->equalTo($this->exceptionConfigPath), $this->equalTo($this->scopeType))->will($this->returnValue(serialize($expressions)));
     }
     $this->assertSame($result, $this->designExceptions->getThemeByRequest($this->requestMock));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:DesignExceptionsTest.php


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