本文整理汇总了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));
}
示例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(''));
}
示例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));
}
示例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);
}
示例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());
}
示例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));
}
示例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);
}
示例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]));
}
示例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());
}
示例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);
}
示例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());
}
示例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));
}
示例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);
}
示例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();
}
示例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));
}