diff options
Diffstat (limited to 'tests/PHPUnit')
7 files changed, 59 insertions, 26 deletions
diff --git a/tests/PHPUnit/Integration/OptionTest.php b/tests/PHPUnit/Integration/OptionTest.php index b487f4f939..dfc279d7ba 100644 --- a/tests/PHPUnit/Integration/OptionTest.php +++ b/tests/PHPUnit/Integration/OptionTest.php @@ -175,4 +175,37 @@ class OptionTest extends IntegrationTestCase Option::deleteLike("%\\_defaultReport"); $this->assertSame('0', Option::get('adefaultReport')); } + + public function testDeleteLike_underscoreNotWildcard() + { + // insert guard - to test unescaped underscore + Option::set('adefaultReport', '1', true); + + Option::deleteLike("adefaul_Report"); // the underscore should not match a character + $this->assertSame('1', Option::get('adefaultReport')); + } + + public function testGetLike() + { + Option::set('adefaultReport', '1', true); + Option::set('adefaultRepo', '1', true); + Option::set('adefaultRepppppppport', '1', true); + + $values = Option::getLike("adefaultRepo%"); // the underscore should not match a character + $this->assertSame(array( + 'adefaultRepo' => '1', + 'adefaultReport' => '1' + ), $values); + } + + public function testGetLike_underscoreNotWildcard() + { + // insert guard - to test unescaped underscore + Option::set('adefaultReport', '1', true); + + $values = Option::getLike("adefaul_Report"); // the underscore should not match a character + $this->assertSame(array(), $values); + $values = Option::getLike("adefaul%Report"); + $this->assertSame(array('adefaultReport' => '1'), $values); + } } diff --git a/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php b/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php index e0d72dd5ae..47f6c5d54b 100644 --- a/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php +++ b/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php @@ -41,7 +41,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase $expected = "<!-- Matomo --> <script type="text/javascript"> - var _paq = window._paq || []; + var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]); _paq.push([\"setCookieDomain\", \"*.localhost\"]); @@ -62,7 +62,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); + g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> <noscript><p><img src="//piwik-server/piwik/matomo.php?idsite=1&amp;rec=1" style="border:0;" alt="" /></p></noscript> @@ -80,7 +80,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase $expected = "<!-- Matomo --> <script type="text/javascript"> - var _paq = window._paq || []; + var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); @@ -89,7 +89,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); + g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> @@ -118,7 +118,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase $expected = "<!-- Matomo --> <script type="text/javascript"> - var _paq = window._paq || []; + var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]);" . ($this->hasCustomVariables() ? " // you can set up to 5 custom variables for each visitor @@ -136,7 +136,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); + g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> @@ -165,7 +165,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase $expected = "<!-- Matomo --> <script type="text/javascript"> - var _paq = window._paq || []; + var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]);" . ($this->hasCustomVariables() ? " // you can set up to 5 custom variables for each visitor @@ -184,7 +184,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); + g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> @@ -209,7 +209,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase $expected = "<!-- Matomo --> <script type="text/javascript"> - var _paq = window._paq || []; + var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]); _paq.push(['trackPageView']); @@ -246,7 +246,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase $expected = '<!-- Matomo --> <script type="text/javascript"> - var _paq = window._paq || []; + var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(["setDocumentTitle", document.domain + "/" + document.title]);' . ($this->hasCustomVariables() ? ' // you can set up to 5 custom variables for each visitor @@ -262,7 +262,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase _paq.push([\'setTrackerUrl\', u+\'matomo.php\']); _paq.push([\'setSiteId\', \'1\']); var d=document, g=d.createElement(\'script\'), s=d.getElementsByTagName(\'script\')[0]; - g.type=\'text/javascript\'; g.async=true; g.defer=true; g.src=u+\'matomo.js\'; s.parentNode.insertBefore(g,s); + g.type=\'text/javascript\'; g.async=true; g.src=u+\'matomo.js\'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> @@ -280,7 +280,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase $expected = '<!-- Matomo --> <script type="text/javascript"> - var _paq = window._paq || []; + var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push([\'trackPageView\']); _paq.push([\'enableLinkTracking\']); @@ -289,7 +289,7 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase _paq.push([\'setTrackerUrl\', u+\'matomo.php\']); _paq.push([\'setSiteId\', \'1\']); var d=document, g=d.createElement(\'script\'), s=d.getElementsByTagName(\'script\')[0]; - g.type=\'text/javascript\'; g.async=true; g.defer=true; g.src=u+\'matomo.js\'; s.parentNode.insertBefore(g,s); + g.type=\'text/javascript\'; g.async=true; g.src=u+\'matomo.js\'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> diff --git a/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldAppear__Actions.getPageUrls_month.xml b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldAppear__Actions.getPageUrls_month.xml index ba5fa49ea6..154dd2715e 100644 --- a/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldAppear__Actions.getPageUrls_month.xml +++ b/tests/PHPUnit/System/expected/test_Archive_InvalidationWebsite2_NewDataShouldAppear__Actions.getPageUrls_month.xml @@ -34,7 +34,7 @@ <entry_nb_actions>18</entry_nb_actions> <entry_sum_visit_length>2</entry_sum_visit_length> <entry_bounce_count>0</entry_bounce_count> - <sum_daily_nb_uniq_visitors>2</sum_daily_nb_uniq_visitors> + <sum_daily_nb_uniq_visitors>3</sum_daily_nb_uniq_visitors> <sum_daily_entry_nb_uniq_visitors>2</sum_daily_entry_nb_uniq_visitors> <avg_time_on_page>0</avg_time_on_page> <bounce_rate>0%</bounce_rate> @@ -51,7 +51,7 @@ <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> <min_bandwidth /> <max_bandwidth /> - <sum_daily_nb_uniq_visitors>2</sum_daily_nb_uniq_visitors> + <sum_daily_nb_uniq_visitors>3</sum_daily_nb_uniq_visitors> <avg_time_on_page>0</avg_time_on_page> <bounce_rate>0%</bounce_rate> <exit_rate>0%</exit_rate> @@ -67,7 +67,7 @@ <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> <min_bandwidth /> <max_bandwidth /> - <sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors> + <sum_daily_nb_uniq_visitors>2</sum_daily_nb_uniq_visitors> <avg_time_on_page>0</avg_time_on_page> <bounce_rate>0%</bounce_rate> <exit_rate>0%</exit_rate> @@ -101,7 +101,7 @@ <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> <min_bandwidth /> <max_bandwidth /> - <sum_daily_nb_uniq_visitors>2</sum_daily_nb_uniq_visitors> + <sum_daily_nb_uniq_visitors>3</sum_daily_nb_uniq_visitors> <avg_bandwidth>0</avg_bandwidth> <avg_page_load_time>0</avg_page_load_time> <avg_time_on_page>0</avg_time_on_page> @@ -119,7 +119,7 @@ <nb_hits_with_bandwidth>0</nb_hits_with_bandwidth> <min_bandwidth /> <max_bandwidth /> - <sum_daily_nb_uniq_visitors>2</sum_daily_nb_uniq_visitors> + <sum_daily_nb_uniq_visitors>3</sum_daily_nb_uniq_visitors> <avg_bandwidth>0</avg_bandwidth> <avg_page_load_time>0</avg_page_load_time> <avg_time_on_page>0</avg_time_on_page> @@ -155,7 +155,7 @@ <min_bandwidth /> <max_bandwidth /> <exit_nb_visits>2</exit_nb_visits> - <sum_daily_nb_uniq_visitors>2</sum_daily_nb_uniq_visitors> + <sum_daily_nb_uniq_visitors>3</sum_daily_nb_uniq_visitors> <sum_daily_exit_nb_uniq_visitors>2</sum_daily_exit_nb_uniq_visitors> <avg_time_on_page>0</avg_time_on_page> <bounce_rate>0%</bounce_rate> diff --git a/tests/PHPUnit/System/expected/test_ImportLogs_siteIdThree_TrackedUsingLogReplayWithFixedSiteId__Live.getLastVisitsDetails_range.xml b/tests/PHPUnit/System/expected/test_ImportLogs_siteIdThree_TrackedUsingLogReplayWithFixedSiteId__Live.getLastVisitsDetails_range.xml index 920abd9f87..cc59d5cde4 100644 --- a/tests/PHPUnit/System/expected/test_ImportLogs_siteIdThree_TrackedUsingLogReplayWithFixedSiteId__Live.getLastVisitsDetails_range.xml +++ b/tests/PHPUnit/System/expected/test_ImportLogs_siteIdThree_TrackedUsingLogReplayWithFixedSiteId__Live.getLastVisitsDetails_range.xml @@ -1806,7 +1806,7 @@ <idVisit>43</idVisit> <visitIp>0.0.0.0</visitIp> - <fingerprint>e8e54c258f211e0c</fingerprint> + <fingerprint>17d589ebdc2ca70b</fingerprint> <actionDetails> <row> <type>action</type> diff --git a/tests/PHPUnit/System/expected/test_ManyVisitorsOneWebsiteTest_pageurlNotContainsSegment__Live.getLastVisitsDetails_month.xml b/tests/PHPUnit/System/expected/test_ManyVisitorsOneWebsiteTest_pageurlNotContainsSegment__Live.getLastVisitsDetails_month.xml index 01d74e6651..887c043ac5 100644 --- a/tests/PHPUnit/System/expected/test_ManyVisitorsOneWebsiteTest_pageurlNotContainsSegment__Live.getLastVisitsDetails_month.xml +++ b/tests/PHPUnit/System/expected/test_ManyVisitorsOneWebsiteTest_pageurlNotContainsSegment__Live.getLastVisitsDetails_month.xml @@ -1409,7 +1409,7 @@ <idVisit>27</idVisit> <visitIp>2003:f6:93bf:26f:9ec7:a6ff:fe29:27df</visitIp> - <fingerprint>b6f1d5120b2b15a2</fingerprint> + <fingerprint>47b25ed9972126db</fingerprint> <actionDetails> <row> <type>action</type> diff --git a/tests/PHPUnit/System/expected/test_apiGetReportMetadata_year__SitesManager.getJavascriptTag.xml b/tests/PHPUnit/System/expected/test_apiGetReportMetadata_year__SitesManager.getJavascriptTag.xml index 17afa1ddc3..2ed83de275 100644 --- a/tests/PHPUnit/System/expected/test_apiGetReportMetadata_year__SitesManager.getJavascriptTag.xml +++ b/tests/PHPUnit/System/expected/test_apiGetReportMetadata_year__SitesManager.getJavascriptTag.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8" ?> <result><!-- Matomo --> <script type="text/javascript"> - var _paq = window._paq || []; + var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); @@ -10,7 +10,7 @@ _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); + g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> diff --git a/tests/PHPUnit/Unit/NonceTest.php b/tests/PHPUnit/Unit/NonceTest.php index 46f1685503..9020257f31 100644 --- a/tests/PHPUnit/Unit/NonceTest.php +++ b/tests/PHPUnit/Unit/NonceTest.php @@ -24,9 +24,9 @@ class NonceTest extends \PHPUnit\Framework\TestCase { return array( // HTTP_HOST => expected - array('example.com', array('http://example.com', 'https://example.com')), - array('example.com:80', array('http://example.com', 'https://example.com')), - array('example.com:443', array('http://example.com', 'https://example.com')), + array('example.com', array('http://example.com', 'https://example.com', 'http://example.com:80', 'https://example.com:443', )), + array('example.com:80', array('http://example.com', 'https://example.com', 'http://example.com:80', 'https://example.com:80')), + array('example.com:443', array('http://example.com', 'https://example.com', 'https://example.com:443')), array('example.com:8080', array('http://example.com', 'https://example.com', 'http://example.com:8080', 'https://example.com:8080')), ); } |