diff options
-rw-r--r-- | libs/PiwikTracker/PiwikTracker.php | 13 | ||||
-rwxr-xr-x | tests/LocalTracker.php | 7 | ||||
-rw-r--r-- | tests/PHPUnit/DatabaseTestCase.php | 3 | ||||
-rwxr-xr-x | tests/PHPUnit/IntegrationTestCase.php | 26 |
4 files changed, 32 insertions, 17 deletions
diff --git a/libs/PiwikTracker/PiwikTracker.php b/libs/PiwikTracker/PiwikTracker.php index 7f609317ca..319ec4ecb7 100644 --- a/libs/PiwikTracker/PiwikTracker.php +++ b/libs/PiwikTracker/PiwikTracker.php @@ -714,9 +714,18 @@ class PiwikTracker * Forces the requests to be recorded for the specified Visitor ID * rather than using the heuristics based on IP and other attributes. * - * This is typically used with the Javascript getVisitorId() function. - * * Allowed only for Admin/Super User, must be used along with setTokenAuth(). + * + * For example, on your website if you use the Javascript tracker in some pages + * and the PHP tracker in other pages, you can write: + * $v->setVisitorId( $v->getVisitorId() ); + * + * This will set this visitor's ID to the ID found in the 1st party Piwik cookies + * (created earlier by the Javascript tracker). + * + * Alternatively you can set the Visitor ID based on a user attribute, for example the user email: + * $v->setVisitorId( substr(md5( $userEmail ), 0, 16)); + * * @see setTokenAuth() * @param string $visitorId 16 hexadecimal characters visitor ID, eg. "33c31e01394bdc63" * @throws Exception diff --git a/tests/LocalTracker.php b/tests/LocalTracker.php index ca53f777d0..961fa17fe3 100755 --- a/tests/LocalTracker.php +++ b/tests/LocalTracker.php @@ -49,11 +49,8 @@ class Piwik_LocalTracker extends PiwikTracker $plugins = Piwik_Config::getInstance()->Plugins['Plugins']; $pluginsTracker = Piwik_Config::getInstance()->Plugins_Tracker['Plugins_Tracker']; $oldTrackerConfig = Piwik_Config::getInstance()->Tracker; - try { - Piwik_PluginsManager::getInstance()->unloadPlugins(); - } catch(Exception $e) { - // this fails for SegmentEditor for some reasons - } + + Piwik_PluginsManager::getInstance()->unloadPlugins(); // modify config $GLOBALS['PIWIK_TRACKER_MODE'] = true; diff --git a/tests/PHPUnit/DatabaseTestCase.php b/tests/PHPUnit/DatabaseTestCase.php index 9f91c7910c..db4186ffb4 100644 --- a/tests/PHPUnit/DatabaseTestCase.php +++ b/tests/PHPUnit/DatabaseTestCase.php @@ -40,7 +40,8 @@ class DatabaseTestCase extends PHPUnit_Framework_TestCase Piwik::createTables(); Piwik::createLogObject(); - Piwik_PluginsManager::getInstance()->loadPlugins(array()); +// Piwik_PluginsManager::getInstance()->loadPlugins(array()); + IntegrationTestCase::loadAllPlugins(); } catch (Exception $e) { $this->fail("TEST INITIALIZATION FAILED: " . $e->getMessage()); diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php index 941828d6a7..e7958db543 100755 --- a/tests/PHPUnit/IntegrationTestCase.php +++ b/tests/PHPUnit/IntegrationTestCase.php @@ -54,6 +54,22 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase } } + /** + * @param $createEmptyDatabase + */ + protected static function installAndLoadPlugins($installPlugins) + { + $pluginsManager = Piwik_PluginsManager::getInstance(); + $plugins = $pluginsManager->readPluginsDirectory(); + + $pluginsManager->loadPlugins($plugins); + if ($installPlugins) + { + $pluginsManager->installLoadedPlugins(); + } + } + + public static function loadAllPlugins() { $pluginsManager = Piwik_PluginsManager::getInstance(); @@ -143,16 +159,8 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase // We need to be SU to create websites for tests Piwik::setUserIsSuperUser(); Piwik_Tracker_Cache::deleteTrackerCache(); + self::installAndLoadPlugins( $installPlugins = $createEmptyDatabase); - // Load and install plugins - $pluginsManager = Piwik_PluginsManager::getInstance(); - $plugins = $pluginsManager->readPluginsDirectory(); - - $pluginsManager->loadPlugins($plugins); - if ($createEmptyDatabase) // only install if database is empty - { - $pluginsManager->installLoadedPlugins(); - } $_GET = $_REQUEST = array(); $_SERVER['HTTP_REFERER'] = ''; |