8 class DataTest extends \PHPUnit\Framework\TestCase
25 protected function setUp()
27 $className = \Magento\GoogleAdwords\Helper\Data::class;
28 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
33 $this->_scopeConfigMock = $context->getScopeConfig();
44 [
true,
'conversionId',
false],
58 $this->_scopeConfigMock->expects(
63 \
Magento\GoogleAdwords\Helper\Data::XML_PATH_ACTIVE
65 $this->returnValue($isActive)
67 $this->_scopeConfigMock->expects($this->any())->method(
'getValue')->with($this->isType(
'string'))->will(
68 $this->returnCallback(
69 function () use ($returnConfigValue) {
70 return $returnConfigValue;
75 $this->assertEquals($returnValue, $this->_helper->isGoogleAdwordsActive());
80 $languages = [
'en',
'ru',
'uk'];
81 $this->_scopeConfigMock->expects(
86 \
Magento\GoogleAdwords\Helper\Data::XML_PATH_LANGUAGES,
89 $this->returnValue($languages)
91 $this->assertEquals($languages, $this->_helper->getLanguageCodes());
100 [
'some-language',
'some-language'],
101 [
'zh_TW',
'zh_Hant'],
102 [
'zh_CN',
'zh_Hans'],
114 $convertArray = [
'zh_TW' =>
'zh_Hant',
'iw' =>
'he',
'zh_CN' =>
'zh_Hans'];
115 $this->_scopeConfigMock->expects(
120 \
Magento\GoogleAdwords\Helper\Data::XML_PATH_LANGUAGE_CONVERT,
123 $this->returnValue($convertArray)
125 $this->assertEquals($returnLanguage, $this->_helper->convertLanguageCodeToLocaleCode($language));
133 'https://www.googleadservices.com/pagead/conversion/%s/?label=%s&guid=ON&script=0',
137 $this->_scopeConfigMock->expects(
142 \
Magento\GoogleAdwords\Helper\Data::XML_PATH_CONVERSION_IMG_SRC,
145 $this->returnValue($imgSrc)
147 $this->assertEquals($imgSrc, $this->_helper->getConversionImgSrc());
152 $jsSrc =
'some-js-src';
153 $this->_scopeConfigMock->expects(
158 \
Magento\GoogleAdwords\Helper\Data::XML_PATH_CONVERSION_JS_SRC
160 $this->returnValue($jsSrc)
162 $this->assertEquals($jsSrc, $this->_helper->getConversionJsSrc());
189 $this->_scopeConfigMock->expects(
196 $this->returnValue($returnValue)
199 $this->assertEquals($returnValue, $this->_helper->{
$method}());
204 $this->_scopeConfigMock->expects($this->once())->method(
'isSetFlag')->willReturn(
true);
206 $this->assertTrue($this->_helper->hasSendConversionValueCurrency());
212 $this->_scopeConfigMock->expects(
217 \
Magento\GoogleAdwords\Helper\Data::XML_PATH_CONVERSION_VALUE_TYPE
219 $this->returnValue(\
Magento\GoogleAdwords\Helper\Data::CONVERSION_VALUE_TYPE_DYNAMIC)
221 $this->_registryMock->expects(
226 \
Magento\GoogleAdwords\Helper\Data::CONVERSION_VALUE_REGISTRY_NAME
228 $this->returnValue($returnValue)
231 $this->assertEquals($returnValue, $this->_helper->getConversionValue());
236 $returnValueCurrency =
'USD';
237 $this->_scopeConfigMock->expects($this->once())->method(
'isSetFlag')->willReturn(
true);
238 $this->_registryMock->expects(
243 \
Magento\GoogleAdwords\Helper\Data::CONVERSION_VALUE_CURRENCY_REGISTRY_NAME
245 $this->returnValue($returnValueCurrency)
248 $this->assertEquals($returnValueCurrency, $this->_helper->getConversionValueCurrency());
266 $this->_scopeConfigMock->expects(
271 \
Magento\GoogleAdwords\Helper\Data::XML_PATH_CONVERSION_VALUE_TYPE
273 $this->returnValue(\
Magento\GoogleAdwords\Helper\Data::CONVERSION_VALUE_TYPE_CONSTANT)
275 $this->_registryMock->expects($this->never())->method(
'registry');
276 $this->_scopeConfigMock->expects(
281 \
Magento\GoogleAdwords\Helper\Data::XML_PATH_CONVERSION_VALUE
283 $this->returnValue($conversionValueConst)
286 $this->assertEquals($returnValue, $this->_helper->getConversionValue());
const XML_PATH_CONVERSION_LABEL
dataProviderForTestIsActive()
testGetConversionValueConstant($conversionValueConst, $returnValue)
dataProviderForTestConvertLanguage()
const XML_PATH_CONVERSION_ID
const XML_PATH_CONVERSION_LANGUAGE
testGetStoreConfigValue($method, $xmlPath, $returnValue)
const XML_PATH_CONVERSION_FORMAT
testGetConversionValueDynamic()
testGetConversionValueCurrency()
testHasSendConversionValueCurrency()
const XML_PATH_CONVERSION_COLOR
dataProviderForTestConversionValueConstant()
const XML_PATH_CONVERSION_VALUE
const CONVERSION_VALUE_DEFAULT
testIsGoogleAdwordsActive($isActive, $returnConfigValue, $returnValue)
testGetConversionImgSrc()
testConvertLanguageCodeToLocaleCode($language, $returnLanguage)
dataProviderForTestStoreConfig()
const XML_PATH_CONVERSION_VALUE_TYPE