本文整理汇总了PHP中Piwik_Common::extractCountryCodeFromBrowserLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Common::extractCountryCodeFromBrowserLanguage方法的具体用法?PHP Piwik_Common::extractCountryCodeFromBrowserLanguage怎么用?PHP Piwik_Common::extractCountryCodeFromBrowserLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Common
的用法示例。
在下文中一共展示了Piwik_Common::extractCountryCodeFromBrowserLanguage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_extractCountryCodeFromBrowserLanguage_Infer
/**
* Data driven tests of extractCountryCodeFromBrowserLanguage
*/
public function test_extractCountryCodeFromBrowserLanguage_Infer()
{
$a1 = array(array("fr,en-us", array("us" => 'amn', "ca" => 'amn'), "us", "fr"), array("fr,en-us", array("fr" => 'eur', "us" => 'amn', "ca" => 'amn'), "us", "fr"), array("fr,fr-fr,en-us", array("fr" => 'eur', "us" => 'amn', "ca" => 'amn'), "fr", "fr"), array("fr-fr,fr,en-us", array("fr" => 'eur', "us" => 'amn', "ca" => 'amn'), "fr", "fr"));
// do not infer country from language
foreach ($a1 as $testdata) {
$this->assertEqual($testdata[2], Piwik_Common::extractCountryCodeFromBrowserLanguage($testdata[0], $testdata[1], $enableLanguageToCountryGuess = false));
}
// infer country from language
foreach ($a1 as $testdata) {
$this->assertEqual($testdata[3], Piwik_Common::extractCountryCodeFromBrowserLanguage($testdata[0], $testdata[1], $enableLanguageToCountryGuess = true));
}
}
示例2: testExtractCountryCodeFromBrowserLanguageInfer
/**
* @dataProvider getCountryCodeTestDataInfer
* @group Core
* @group Common
* @group extractCountryCodeFromBrowserLanguage
*/
public function testExtractCountryCodeFromBrowserLanguageInfer($browserLanguage, $validCountries, $expected, $expectedInfer)
{
include "DataFiles/LanguageToCountry.php";
// do not infer country from language
$this->assertEquals($expected, Piwik_Common::extractCountryCodeFromBrowserLanguage($browserLanguage, $validCountries, $enableLanguageToCountryGuess = false));
// infer country from language
$this->assertEquals($expectedInfer, Piwik_Common::extractCountryCodeFromBrowserLanguage($browserLanguage, $validCountries, $enableLanguageToCountryGuess = true));
}