From dd0d8502de32093c145f5936ef60b7d56d5f56ff Mon Sep 17 00:00:00 2001
From: mattab <matthieu.aubry@gmail.com>
Date: Mon, 8 Sep 2014 22:08:40 +1200
Subject: [PATCH] Refs #3490 Docs, and fix a few tests, more to come

---
 libs/PiwikTracker/PiwikTracker.php                        | 2 +-
 plugins/API/ProcessedReport.php                           | 1 +
 ...blesIntegrationTest__Live.getLastVisitsDetails_day.xml | 1 +
 tests/PHPUnit/Impl/TestRequestResponse.php                | 4 ++--
 ...test_apiGetReportMetadata__API.getSegmentsMetadata.xml | 8 ++++++++
 5 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/libs/PiwikTracker/PiwikTracker.php b/libs/PiwikTracker/PiwikTracker.php
index 8583ee1e06..c6629d4473 100644
--- a/libs/PiwikTracker/PiwikTracker.php
+++ b/libs/PiwikTracker/PiwikTracker.php
@@ -948,7 +948,7 @@ class PiwikTracker
     }
 
     /**
-     * The User ID is a string representing a given user in your system.
+     * Force the action to be recorded for a specific User. The User ID is a string representing a given user in your system.
      *
      * A User ID can be a username, UUID or an email address, or any number or string that uniquely identifies a user or client.
      *
diff --git a/plugins/API/ProcessedReport.php b/plugins/API/ProcessedReport.php
index e174d3e4a4..3111ae5ae9 100644
--- a/plugins/API/ProcessedReport.php
+++ b/plugins/API/ProcessedReport.php
@@ -39,6 +39,7 @@ class ProcessedReport
 
         foreach ($reportsMetadata as $report) {
             // See ArchiveProcessor/Aggregator.php - unique visitors are not processed for period != day
+            // todo: should use SettingsPiwik::isUniqueVisitorsEnabled instead
             if (($period && $period != 'day') && !($apiModule == 'VisitsSummary' && $apiAction == 'get')) {
                 unset($report['metrics']['nb_uniq_visitors']);
             }
diff --git a/plugins/CustomVariables/tests/processed/test_CustomVariablesIntegrationTest__Live.getLastVisitsDetails_day.xml b/plugins/CustomVariables/tests/processed/test_CustomVariablesIntegrationTest__Live.getLastVisitsDetails_day.xml
index 463462262e..5d1eec5750 100644
--- a/plugins/CustomVariables/tests/processed/test_CustomVariablesIntegrationTest__Live.getLastVisitsDetails_day.xml
+++ b/plugins/CustomVariables/tests/processed/test_CustomVariablesIntegrationTest__Live.getLastVisitsDetails_day.xml
@@ -4,6 +4,7 @@
 		<idSite>1</idSite>
 		<idVisit>1</idVisit>
 		<visitIp>156.5.3.2</visitIp>
+		<userId />
 		
 		<actionDetails>
 			<row>
diff --git a/tests/PHPUnit/Impl/TestRequestResponse.php b/tests/PHPUnit/Impl/TestRequestResponse.php
index 923e53088e..1f4bae3ebb 100644
--- a/tests/PHPUnit/Impl/TestRequestResponse.php
+++ b/tests/PHPUnit/Impl/TestRequestResponse.php
@@ -82,7 +82,7 @@ class TestRequestResponse
     private function normalizeApiResponse($apiResponse)
     {
         if ($this->shouldDeleteLiveIds()) {
-            $this->removeAllIdsFromXml($apiResponse);
+            $apiResponse = $this->removeAllIdsFromXml($apiResponse);
         }
 
         if ($this->shouldDeleteLiveDates()) {
@@ -225,7 +225,7 @@ class TestRequestResponse
 
     private function shouldDeleteLiveIds()
     {
-        return empty($this->params['keepLiveDates']);
+        return empty($this->params['keepLiveIds']);
     }
 
     private function shouldDeleteLiveDates()
diff --git a/tests/PHPUnit/Integration/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml b/tests/PHPUnit/Integration/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml
index 19aefaace8..5b0389fd95 100644
--- a/tests/PHPUnit/Integration/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml
+++ b/tests/PHPUnit/Integration/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml
@@ -156,6 +156,14 @@
 		<segment>visitServerHour</segment>
 		<acceptedValues>0, 1, 2, 3, ..., 20, 21, 22, 23</acceptedValues>
 	</row>
+	<row>
+		<type>dimension</type>
+		<category>Visit</category>
+		<name>User ID</name>
+		<segment>userId</segment>
+		<acceptedValues>any non empty unique string identifying the user (such as an email address or a username).</acceptedValues>
+		<permission>1</permission>
+	</row>
 	<row>
 		<type>dimension</type>
 		<category>Visit</category>
-- 
GitLab