From 0e5d1ad2fecef5c83159b781d706cf33bfd6d440 Mon Sep 17 00:00:00 2001
From: Benaka Moorthi <benaka.moorthi@gmail.com>
Date: Thu, 29 Aug 2013 05:42:18 -0400
Subject: [PATCH] Refs #3089, add integration test files for new Live API
 methods.

---
 ...NormalAPI__Live.getMostRecentVisitorId.xml |   2 +
 ...taAndNormalAPI__Live.getVisitorProfile.xml | 245 ++++++++++++++++++
 tests/PHPUnit/IntegrationTestCase.php         |   7 +-
 3 files changed, 252 insertions(+), 2 deletions(-)
 create mode 100644 tests/PHPUnit/Integration/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__Live.getMostRecentVisitorId.xml
 create mode 100644 tests/PHPUnit/Integration/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__Live.getVisitorProfile.xml

diff --git a/tests/PHPUnit/Integration/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__Live.getMostRecentVisitorId.xml b/tests/PHPUnit/Integration/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__Live.getMostRecentVisitorId.xml
new file mode 100644
index 0000000000..943e78b64e
--- /dev/null
+++ b/tests/PHPUnit/Integration/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__Live.getMostRecentVisitorId.xml
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<result>61e8cc2d51fea26d</result>
\ No newline at end of file
diff --git a/tests/PHPUnit/Integration/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__Live.getVisitorProfile.xml b/tests/PHPUnit/Integration/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__Live.getVisitorProfile.xml
new file mode 100644
index 0000000000..7d6129788c
--- /dev/null
+++ b/tests/PHPUnit/Integration/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__Live.getVisitorProfile.xml
@@ -0,0 +1,245 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<result>
+	<totalVisits>2</totalVisits>
+	<totalVisitDuration>361</totalVisitDuration>
+	<totalActionCount>2</totalActionCount>
+	<totalGoalConversions>1</totalGoalConversions>
+	<totalConversionsByGoal>
+		<row key="1">1</row>
+	</totalConversionsByGoal>
+	<countries>fr</countries>
+	<continents>eur</continents>
+	<totalVisitDurationPretty>6 min 1s</totalVisitDurationPretty>
+	<firstVisit>
+		<date>2013-08-29</date>
+		<prettyDate>29 Aug 2013</prettyDate>
+		<daysAgo>0</daysAgo>
+		<referralSummary>Direct Entry</referralSummary>
+	</firstVisit>
+	<lastVisit>
+		<date>2013-08-29</date>
+		<prettyDate>29 Aug 2013</prettyDate>
+		<daysAgo>0</daysAgo>
+		<referralSummary>Direct Entry</referralSummary>
+	</lastVisit>
+	<lastVisits>
+		<row>
+			<idSite>1</idSite>
+			<idVisit>3</idVisit>
+			<visitIp>156.5.3.2</visitIp>
+			<visitorId>61e8cc2d51fea26d</visitorId>
+			<visitorType>new</visitorType>
+			<visitorTypeIcon />
+			<visitConverted>0</visitConverted>
+			<visitConvertedIcon />
+			<visitEcommerceStatus>none</visitEcommerceStatus>
+			<visitEcommerceStatusIcon />
+			<searches>0</searches>
+			<actions>1</actions>
+			<actionDetails>
+				<row>
+					<type>outlink</type>
+					<url>http://test.com</url>
+					<pageTitle />
+					<pageIdAction>6</pageIdAction>
+					<pageId>5</pageId>
+					<serverTimePretty>Thu 29 Aug 10:35:33</serverTimePretty>
+					<icon>plugins/Zeitgeist/images/link.gif</icon>
+				</row>
+			</actionDetails>
+			<customVariables>
+				<row>
+					<customVariableName1>VisitorType</customVariableName1>
+					<customVariableValue1>LoggedOut</customVariableValue1>
+				</row>
+				<row>
+					<customVariableName2>Othercustom value which should be truncated abcdefghijklmnopqrstuvwxyz</customVariableName2>
+					<customVariableValue2>abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</customVariableValue2>
+				</row>
+			</customVariables>
+			<goalConversions>0</goalConversions>
+			<siteCurrency>USD</siteCurrency>
+			<siteCurrencySymbol>$</siteCurrencySymbol>
+			<serverDate>2013-08-29</serverDate>
+			<visitLocalTime>12:34:06</visitLocalTime>
+			<visitLocalHour>12</visitLocalHour>
+			<visitServerHour>10</visitServerHour>
+			<firstActionTimestamp>1377772533</firstActionTimestamp>
+			<lastActionTimestamp>1377772533</lastActionTimestamp>
+			<lastActionDateTime>2013-08-29 10:35:33</lastActionDateTime>
+			<visitDuration>0</visitDuration>
+			<visitDurationPretty>0s</visitDurationPretty>
+			<visitCount>1</visitCount>
+			<daysSinceLastVisit>0</daysSinceLastVisit>
+			<daysSinceFirstVisit>0</daysSinceFirstVisit>
+			<daysSinceLastEcommerceOrder>0</daysSinceLastEcommerceOrder>
+			<continent>Europe</continent>
+			<continentCode>eur</continentCode>
+			<country>France</country>
+			<countryCode>fr</countryCode>
+			<countryFlag>plugins/UserCountry/images/flags/fr.png</countryFlag>
+			<region />
+			<regionCode />
+			<city />
+			<location>France</location>
+			<latitude />
+			<longitude />
+			<provider>Unknown</provider>
+			<providerName>Unknown</providerName>
+			<providerUrl>http://piwik.org/faq/general/#faq_52</providerUrl>
+			<referrerType>direct</referrerType>
+			<referrerTypeName>Direct Entry</referrerTypeName>
+			<referrerName />
+			<referrerKeyword />
+			<referrerKeywordPosition />
+			<referrerUrl />
+			<referrerSearchEngineUrl />
+			<referrerSearchEngineIcon />
+			<operatingSystem>Windows XP</operatingSystem>
+			<operatingSystemCode>WXP</operatingSystemCode>
+			<operatingSystemShortName>Win XP</operatingSystemShortName>
+			<operatingSystemIcon>plugins/UserSettings/images/os/WXP.gif</operatingSystemIcon>
+			<browserFamily>gecko</browserFamily>
+			<browserFamilyDescription>Gecko (Firefox)</browserFamilyDescription>
+			<browserName>Firefox 3.0</browserName>
+			<browserIcon>plugins/UserSettings/images/browsers/FF.gif</browserIcon>
+			<browserCode>FF</browserCode>
+			<browserVersion>3.0</browserVersion>
+			<screenType>dual</screenType>
+			<deviceType>desktop</deviceType>
+			<resolution>1111x222</resolution>
+			<screenTypeIcon>plugins/UserSettings/images/screens/dual.gif</screenTypeIcon>
+			<plugins>flash, java</plugins>
+			<pluginsIcons>
+				<row>
+					<pluginIcon>plugins/UserSettings/images/plugins/flash.gif</pluginIcon>
+					<pluginName>flash</pluginName>
+				</row>
+				<row>
+					<pluginIcon>plugins/UserSettings/images/plugins/java.gif</pluginIcon>
+					<pluginName>java</pluginName>
+				</row>
+			</pluginsIcons>
+			<serverTimestamp>1377772533</serverTimestamp>
+			<serverTimePretty>10:35:33</serverTimePretty>
+			<serverDatePretty>Thu 29 Aug</serverDatePretty>
+			<serverDatePrettyFirstAction>29 Aug 2013</serverDatePrettyFirstAction>
+			<serverTimePrettyFirstAction>10:35:33</serverTimePrettyFirstAction>
+		</row>
+		<row>
+			<idSite>1</idSite>
+			<idVisit>2</idVisit>
+			<visitIp>156.5.3.2</visitIp>
+			<visitorId>61e8cc2d51fea26d</visitorId>
+			<visitorType>new</visitorType>
+			<visitorTypeIcon />
+			<visitConverted>1</visitConverted>
+			<visitConvertedIcon>plugins/Zeitgeist/images/goal.png</visitConvertedIcon>
+			<visitEcommerceStatus>none</visitEcommerceStatus>
+			<visitEcommerceStatusIcon />
+			<searches>0</searches>
+			<actions>1</actions>
+			<actionDetails>
+				<row>
+					<type>goal</type>
+					<goalName>triggered js</goalName>
+					<goalId>1</goalId>
+					<revenue>0</revenue>
+					<goalPageId />
+					<serverTimePretty>Thu 29 Aug 09:35:33</serverTimePretty>
+					<url>http://example.org/homepage</url>
+					<icon>plugins/Zeitgeist/images/goal.png</icon>
+				</row>
+				<row>
+					<type>action</type>
+					<url>http://example.org/homepage</url>
+					<pageTitle>Homepage</pageTitle>
+					<pageIdAction>2</pageIdAction>
+					<pageId>4</pageId>
+					<serverTimePretty>Thu 29 Aug 09:41:33</serverTimePretty>
+					<icon />
+				</row>
+			</actionDetails>
+			<customVariables>
+				<row>
+					<customVariableName1>VisitorType</customVariableName1>
+					<customVariableValue1>LoggedOut</customVariableValue1>
+				</row>
+				<row>
+					<customVariableName2>Othercustom value which should be truncated abcdefghijklmnopqrstuvwxyz</customVariableName2>
+					<customVariableValue2>abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</customVariableValue2>
+				</row>
+			</customVariables>
+			<goalConversions>1</goalConversions>
+			<siteCurrency>USD</siteCurrency>
+			<siteCurrencySymbol>$</siteCurrencySymbol>
+			<serverDate>2013-08-29</serverDate>
+			<visitLocalTime>12:34:06</visitLocalTime>
+			<visitLocalHour>12</visitLocalHour>
+			<visitServerHour>9</visitServerHour>
+			<firstActionTimestamp>1377768933</firstActionTimestamp>
+			<lastActionTimestamp>1377769293</lastActionTimestamp>
+			<lastActionDateTime>2013-08-29 09:41:33</lastActionDateTime>
+			<visitDuration>361</visitDuration>
+			<visitDurationPretty>6 min 1s</visitDurationPretty>
+			<visitCount>1</visitCount>
+			<daysSinceLastVisit>0</daysSinceLastVisit>
+			<daysSinceFirstVisit>0</daysSinceFirstVisit>
+			<daysSinceLastEcommerceOrder>0</daysSinceLastEcommerceOrder>
+			<continent>Europe</continent>
+			<continentCode>eur</continentCode>
+			<country>France</country>
+			<countryCode>fr</countryCode>
+			<countryFlag>plugins/UserCountry/images/flags/fr.png</countryFlag>
+			<region />
+			<regionCode />
+			<city />
+			<location>France</location>
+			<latitude />
+			<longitude />
+			<provider>Unknown</provider>
+			<providerName>Unknown</providerName>
+			<providerUrl>http://piwik.org/faq/general/#faq_52</providerUrl>
+			<referrerType>direct</referrerType>
+			<referrerTypeName>Direct Entry</referrerTypeName>
+			<referrerName />
+			<referrerKeyword />
+			<referrerKeywordPosition />
+			<referrerUrl />
+			<referrerSearchEngineUrl />
+			<referrerSearchEngineIcon />
+			<operatingSystem>Windows XP</operatingSystem>
+			<operatingSystemCode>WXP</operatingSystemCode>
+			<operatingSystemShortName>Win XP</operatingSystemShortName>
+			<operatingSystemIcon>plugins/UserSettings/images/os/WXP.gif</operatingSystemIcon>
+			<browserFamily>gecko</browserFamily>
+			<browserFamilyDescription>Gecko (Firefox)</browserFamilyDescription>
+			<browserName>Firefox 3.0</browserName>
+			<browserIcon>plugins/UserSettings/images/browsers/FF.gif</browserIcon>
+			<browserCode>FF</browserCode>
+			<browserVersion>3.0</browserVersion>
+			<screenType>dual</screenType>
+			<deviceType>desktop</deviceType>
+			<resolution>1111x222</resolution>
+			<screenTypeIcon>plugins/UserSettings/images/screens/dual.gif</screenTypeIcon>
+			<plugins>flash, java</plugins>
+			<pluginsIcons>
+				<row>
+					<pluginIcon>plugins/UserSettings/images/plugins/flash.gif</pluginIcon>
+					<pluginName>flash</pluginName>
+				</row>
+				<row>
+					<pluginIcon>plugins/UserSettings/images/plugins/java.gif</pluginIcon>
+					<pluginName>java</pluginName>
+				</row>
+			</pluginsIcons>
+			<serverTimestamp>1377769293</serverTimestamp>
+			<serverTimePretty>09:41:33</serverTimePretty>
+			<serverDatePretty>Thu 29 Aug</serverDatePretty>
+			<serverDatePrettyFirstAction>29 Aug 2013</serverDatePrettyFirstAction>
+			<serverTimePrettyFirstAction>09:35:33</serverTimePrettyFirstAction>
+		</row>
+	</lastVisits>
+	<nextVisitorId>df7630bf363ed030</nextVisitorId>
+	<prevVisitorId>0</prevVisitorId>
+</result>
\ No newline at end of file
diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php
index b3d7cbeb1e..308e2c8fc3 100755
--- a/tests/PHPUnit/IntegrationTestCase.php
+++ b/tests/PHPUnit/IntegrationTestCase.php
@@ -276,7 +276,7 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
         'Annotations',
         'SegmentEditor',
         'UserCountry.getLocationFromIP',
-        'Dashboard'
+        'Dashboard',
     );
 
     const DEFAULT_USER_PASSWORD = 'nopass';
@@ -714,7 +714,8 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
     protected function _testApiUrl($testName, $apiId, $requestUrl)
     {
         $isTestLogImportReverseChronological = strpos($testName, 'ImportedInRandomOrderTest') === false;
-        $isLiveMustDeleteDates = strpos($requestUrl, 'Live.getLastVisits') !== false
+        $isLiveMustDeleteDates = (strpos($requestUrl, 'Live.getLastVisits') !== false
+                                  || strpos($requestUrl, 'Live.getVisitorProfile') !== false)
                                 // except for that particular test that we care about dates!
                                 && $isTestLogImportReverseChronological;
 
@@ -840,6 +841,8 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
             'goalTimePretty',
             'serverTimePretty',
             'visitorId',
+            'nextVisitorId',
+            'prevVisitorId',
             'visitServerHour',
         );
         foreach ($toRemove as $xml) {
-- 
GitLab