From c12c7792361d785fb7ccc0fef0befda9c3a7d742 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Thu, 8 Oct 2015 08:17:11 -0700 Subject: Split up UserSettings BC (move request forwarding to appropriate plugins) & split up the tests for that BC. --- plugins/DevicePlugins/DevicePlugins.php | 7 ++ .../tests/System/UserSettingsBCTest.php | 78 ++++++++++++++++++++++ ...serSettings.getPlugin___API.getMetadata_day.xml | 23 +++++++ ...ngs.getPlugin___DevicePlugins.getPlugin_day.xml | 63 +++++++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 plugins/DevicePlugins/tests/System/UserSettingsBCTest.php create mode 100644 plugins/DevicePlugins/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getPlugin___API.getMetadata_day.xml create mode 100644 plugins/DevicePlugins/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getPlugin___DevicePlugins.getPlugin_day.xml (limited to 'plugins/DevicePlugins') diff --git a/plugins/DevicePlugins/DevicePlugins.php b/plugins/DevicePlugins/DevicePlugins.php index 3ac882e8ce..5ddc6d15d3 100644 --- a/plugins/DevicePlugins/DevicePlugins.php +++ b/plugins/DevicePlugins/DevicePlugins.php @@ -25,6 +25,7 @@ class DevicePlugins extends \Piwik\Plugin return array( 'Metrics.getDefaultMetricTranslations' => 'addMetricTranslations', 'Live.getAllVisitorDetails' => 'extendVisitorDetails', + 'Request.getRenamedModuleAndAction' => 'renameUserSettingsModuleAndAction', ); } @@ -45,4 +46,10 @@ class DevicePlugins extends \Piwik\Plugin $translations = array_merge($translations, $metrics); } + public function renameUserSettingsModuleAndAction(&$module, &$action) + { + if ($module == 'UserSettings' && $action == 'getPlugin') { + $module = 'DevicePlugins'; + } + } } diff --git a/plugins/DevicePlugins/tests/System/UserSettingsBCTest.php b/plugins/DevicePlugins/tests/System/UserSettingsBCTest.php new file mode 100644 index 0000000000..1901960abb --- /dev/null +++ b/plugins/DevicePlugins/tests/System/UserSettingsBCTest.php @@ -0,0 +1,78 @@ +runApiTests($api, $params); + } + + public function getApiForTesting() + { + $idSite = self::$fixture->idSite; + $dateTime = self::$fixture->dateTime; + + $api = array( + 'UserSettings.getPlugin', + ); + + $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 DevicePlugins & overwrite the module & action w/ otherRequestParameters) + $result[] = array('DevicePlugins.getPlugin', 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/DevicePlugins/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getPlugin___API.getMetadata_day.xml b/plugins/DevicePlugins/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getPlugin___API.getMetadata_day.xml new file mode 100644 index 0000000000..9a4f403963 --- /dev/null +++ b/plugins/DevicePlugins/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getPlugin___API.getMetadata_day.xml @@ -0,0 +1,23 @@ + + + + Visitor Settings + Browser Plugins + DevicePlugins + getPlugin + Plugin + This report shows which browser plugins your visitors had enabled. This information might be important for choosing the right way to deliver your content. + + 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. + + + % Visits + + 1 + index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=DevicePlugins&apiAction=getPlugin&period=day&date=2010-03-06 + DevicePlugins_getPlugin + + \ No newline at end of file diff --git a/plugins/DevicePlugins/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getPlugin___DevicePlugins.getPlugin_day.xml b/plugins/DevicePlugins/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getPlugin___DevicePlugins.getPlugin_day.xml new file mode 100644 index 0000000000..72728977e1 --- /dev/null +++ b/plugins/DevicePlugins/tests/System/expected/test_UserSettingsBCTestUserSettings_UserSettings.getPlugin___DevicePlugins.getPlugin_day.xml @@ -0,0 +1,63 @@ + + + + + 2 + 100% + plugins/DevicePlugins/images/plugins/cookie.gif + + + + 2 + 100% + plugins/DevicePlugins/images/plugins/flash.gif + + + + 2 + 100% + plugins/DevicePlugins/images/plugins/java.gif + + + + 0 + 0% + plugins/DevicePlugins/images/plugins/director.gif + + + + 0 + 0% + plugins/DevicePlugins/images/plugins/gears.gif + + + + 0 + 0% + plugins/DevicePlugins/images/plugins/pdf.gif + + + + 0 + 0% + plugins/DevicePlugins/images/plugins/quicktime.gif + + + + 0 + 0% + plugins/DevicePlugins/images/plugins/realplayer.gif + + + + 0 + 0% + plugins/DevicePlugins/images/plugins/silverlight.gif + + + + 0 + 0% + plugins/DevicePlugins/images/plugins/windowsmedia.gif + + \ No newline at end of file -- cgit v1.2.3