diff options
Diffstat (limited to 'plugins/UserLanguage')
6 files changed, 188 insertions, 2 deletions
diff --git a/plugins/UserLanguage/UserLanguage.php b/plugins/UserLanguage/UserLanguage.php index be892d4196..7bb409a5e3 100644 --- a/plugins/UserLanguage/UserLanguage.php +++ b/plugins/UserLanguage/UserLanguage.php @@ -22,7 +22,8 @@ class UserLanguage extends \Piwik\Plugin public function registerEvents() { return array( - 'Live.getAllVisitorDetails' => 'extendVisitorDetails' + 'Live.getAllVisitorDetails' => 'extendVisitorDetails', + 'Request.getRenamedModuleAndAction' => 'renameUserSettingsModuleAndAction', ); } @@ -44,4 +45,11 @@ class UserLanguage extends \Piwik\Plugin $out .= '<h2 piwik-enriched-headline>' . Piwik::translate('UserLanguage_BrowserLanguage') . '</h2>'; $out .= FrontController::getInstance()->fetchDispatch('UserLanguage', 'getLanguage'); } -}
\ No newline at end of file + + public function renameUserSettingsModuleAndAction(&$module, &$action) + { + if ($module == 'UserSettings' && ($action == 'getLanguage' || $action == 'getLanguageCode')) { + $module = 'UserLanguage'; + } + } +} diff --git a/plugins/UserLanguage/tests/System/UserSettingsBCTest.php b/plugins/UserLanguage/tests/System/UserSettingsBCTest.php new file mode 100644 index 0000000000..208048b8cc --- /dev/null +++ b/plugins/UserLanguage/tests/System/UserSettingsBCTest.php @@ -0,0 +1,78 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Plugins\UserLanguage\tests\System; + +use Piwik\Tests\Fixtures\OneVisitorTwoVisits; +use Piwik\Tests\Framework\TestCase\SystemTestCase; + +/** + * @group UserLanguage + * @group UserLanguage_System + */ +class UserSettingsBCTest extends SystemTestCase +{ + /** + * @var OneVisitorTwoVisits + */ + public static $fixture; + + /** + * @dataProvider getApiForTesting + */ + public function test_Api($api, $params) + { + $this->runApiTests($api, $params); + } + + public function getApiForTesting() + { + $idSite = self::$fixture->idSite; + $dateTime = self::$fixture->dateTime; + + $api = array( + 'UserSettings.getLanguage', + 'UserSettings.getLanguageCode', + ); + + $result = array(); + + foreach ($api as $method) { + list($module, $action) = explode('.', $method); + + // api test (uses hack to test UserSettings which doesn't exist anymore. we say we're testing + // against UserLanguage & overwrite the module & action w/ otherRequestParameters) + $result[] = array('UserLanguage.getLanguage', array('idSite' => $idSite, + 'date' => $dateTime, + 'periods' => array('day'), + 'testSuffix' => $module . '_' . $method . '_', + 'otherRequestParameters' => array( + 'method' => $method, + ), + )); + + // api metadata tests + $result[] = array('API.getMetadata', array( + 'idSite' => $idSite, + 'date' => $dateTime, + 'apiModule' => $module, + 'apiAction' => $action, + 'testSuffix' => $module . '_' . $method . '_', + )); + } + + return $result; + } + + public static function getPathToTestDirectory() + { + return dirname(__FILE__); + } +} + +UserSettingsBCTest::$fixture = new OneVisitorTwoVisits();
\ No newline at end of file diff --git a/plugins/UserLanguage/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getLanguageCode___API.getMetadata_day.xml b/plugins/UserLanguage/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getLanguageCode___API.getMetadata_day.xml new file mode 100644 index 0000000000..9bf598e68f --- /dev/null +++ b/plugins/UserLanguage/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getLanguageCode___API.getMetadata_day.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <row> + <category>Visitor Settings</category> + <name>Language code</name> + <module>UserLanguage</module> + <action>getLanguageCode</action> + <dimension>Language</dimension> + <metrics> + <nb_visits>Visits</nb_visits> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_actions>Actions</nb_actions> + <nb_users>Users</nb_users> + </metrics> + <metricsDocumentation> + <nb_visits>If a visitor comes to your website for the first time or if he visits a page more than 30 minutes after his last page view, this will be recorded as a new visit.</nb_visits> + <nb_uniq_visitors>The number of unduplicated visitors coming to your website. Every user is only counted once, even if he visits the website multiple times a day.</nb_uniq_visitors> + <nb_actions>The number of actions performed by your visitors. Actions can be page views, internal site searches, downloads or outlinks.</nb_actions> + <nb_users>The number of users logged in your website. It is the number of unique active users that have a User ID set (via the Tracking code function 'setUserId').</nb_users> + <nb_actions_per_visit>The average number of actions (page views, site searches, downloads or outlinks) that were performed during the visits.</nb_actions_per_visit> + <avg_time_on_site>The average duration of a visit.</avg_time_on_site> + <bounce_rate>The percentage of visits that only had a single pageview. This means, that the visitor left the website directly from the entrance page.</bounce_rate> + <conversion_rate>The percentage of visits that triggered a goal conversion.</conversion_rate> + </metricsDocumentation> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + <conversion_rate>Conversion Rate</conversion_rate> + </processedMetrics> + <imageGraphUrl>index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=UserLanguage&apiAction=getLanguageCode&period=day&date=2010-03-06</imageGraphUrl> + <imageGraphEvolutionUrl>index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=UserLanguage&apiAction=getLanguageCode&period=day&date=2010-02-05,2010-03-06</imageGraphEvolutionUrl> + <uniqueId>UserLanguage_getLanguageCode</uniqueId> + </row> +</result>
\ No newline at end of file diff --git a/plugins/UserLanguage/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getLanguageCode___UserLanguage.getLanguage_day.xml b/plugins/UserLanguage/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getLanguageCode___UserLanguage.getLanguage_day.xml new file mode 100644 index 0000000000..de31fc9d35 --- /dev/null +++ b/plugins/UserLanguage/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getLanguageCode___UserLanguage.getLanguage_day.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <row> + <label>French (fr)</label> + <nb_uniq_visitors>1</nb_uniq_visitors> + <nb_visits>2</nb_visits> + <nb_actions>8</nb_actions> + <nb_users>0</nb_users> + <max_actions>7</max_actions> + <sum_visit_length>1621</sum_visit_length> + <bounce_count>1</bounce_count> + <nb_visits_converted>2</nb_visits_converted> + <segment>languageCode==fr</segment> + </row> +</result>
\ No newline at end of file diff --git a/plugins/UserLanguage/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getLanguage___API.getMetadata_day.xml b/plugins/UserLanguage/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getLanguage___API.getMetadata_day.xml new file mode 100644 index 0000000000..9e886e4c3f --- /dev/null +++ b/plugins/UserLanguage/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getLanguage___API.getMetadata_day.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <row> + <category>Visitor Settings</category> + <name>Browser language</name> + <module>UserLanguage</module> + <action>getLanguage</action> + <dimension>Language</dimension> + <metrics> + <nb_visits>Visits</nb_visits> + <nb_uniq_visitors>Unique visitors</nb_uniq_visitors> + <nb_actions>Actions</nb_actions> + <nb_users>Users</nb_users> + </metrics> + <metricsDocumentation> + <nb_visits>If a visitor comes to your website for the first time or if he visits a page more than 30 minutes after his last page view, this will be recorded as a new visit.</nb_visits> + <nb_uniq_visitors>The number of unduplicated visitors coming to your website. Every user is only counted once, even if he visits the website multiple times a day.</nb_uniq_visitors> + <nb_actions>The number of actions performed by your visitors. Actions can be page views, internal site searches, downloads or outlinks.</nb_actions> + <nb_users>The number of users logged in your website. It is the number of unique active users that have a User ID set (via the Tracking code function 'setUserId').</nb_users> + <nb_actions_per_visit>The average number of actions (page views, site searches, downloads or outlinks) that were performed during the visits.</nb_actions_per_visit> + <avg_time_on_site>The average duration of a visit.</avg_time_on_site> + <bounce_rate>The percentage of visits that only had a single pageview. This means, that the visitor left the website directly from the entrance page.</bounce_rate> + <conversion_rate>The percentage of visits that triggered a goal conversion.</conversion_rate> + </metricsDocumentation> + <processedMetrics> + <nb_actions_per_visit>Actions per Visit</nb_actions_per_visit> + <avg_time_on_site>Avg. Time on Website</avg_time_on_site> + <bounce_rate>Bounce Rate</bounce_rate> + <conversion_rate>Conversion Rate</conversion_rate> + </processedMetrics> + <imageGraphUrl>index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=UserLanguage&apiAction=getLanguage&period=day&date=2010-03-06</imageGraphUrl> + <imageGraphEvolutionUrl>index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=UserLanguage&apiAction=getLanguage&period=day&date=2010-02-05,2010-03-06</imageGraphEvolutionUrl> + <uniqueId>UserLanguage_getLanguage</uniqueId> + </row> +</result>
\ No newline at end of file diff --git a/plugins/UserLanguage/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getLanguage___UserLanguage.getLanguage_day.xml b/plugins/UserLanguage/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getLanguage___UserLanguage.getLanguage_day.xml new file mode 100644 index 0000000000..2e95d73c83 --- /dev/null +++ b/plugins/UserLanguage/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getLanguage___UserLanguage.getLanguage_day.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8" ?> +<result> + <row> + <label>French</label> + <nb_uniq_visitors>1</nb_uniq_visitors> + <nb_visits>2</nb_visits> + <nb_actions>8</nb_actions> + <nb_users>0</nb_users> + <max_actions>7</max_actions> + <sum_visit_length>1621</sum_visit_length> + <bounce_count>1</bounce_count> + <nb_visits_converted>2</nb_visits_converted> + <segment>languageCode==fr,languageCode=@fr-</segment> + </row> +</result>
\ No newline at end of file |