Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2015-11-17 07:03:04 +0300
committerThomas Steur <thomas.steur@gmail.com>2015-11-19 07:14:31 +0300
commit433c5c93a8524bd5d4dec7c6f73bc8dca957cb66 (patch)
treef95d8f47d6f716e0199f3c9222f472daa14dae17 /tests
parent1de540f1003eb303f73098ae690a8ef366977d2f (diff)
refs #8076 #9224 adding new segment ActionUrl + new operators starts with and ends with
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/Integration/SegmentTest.php26
-rw-r--r--tests/PHPUnit/System/AutoSuggestAPITest.php1
-rwxr-xr-xtests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentContainsTest.php7
-rwxr-xr-xtests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php2
-rw-r--r--tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionUrl__API.getSuggestedValuesForSegment.xml23
-rw-r--r--tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionUrl__VisitsSummary.get_range.xml12
-rw-r--r--tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml11
-rw-r--r--tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageTitleEndsWith__Actions.getPageTitles_day.xml30
-rw-r--r--tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageTitleStartsWith__Actions.getPageTitles_day.xml25
-rw-r--r--tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageUrlEndsWith__Actions.getPageUrls_day.xml28
-rw-r--r--tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageUrlStartsWith__Actions.getPageUrls_day.xml22
-rw-r--r--tests/PHPUnit/Unit/Segment/SegmentExpressionTest.php3
12 files changed, 188 insertions, 2 deletions
diff --git a/tests/PHPUnit/Integration/SegmentTest.php b/tests/PHPUnit/Integration/SegmentTest.php
index 9179c6d61a..f88d1248f6 100644
--- a/tests/PHPUnit/Integration/SegmentTest.php
+++ b/tests/PHPUnit/Integration/SegmentTest.php
@@ -446,6 +446,32 @@ class SegmentTest extends IntegrationTestCase
$this->assertEquals($this->removeExtraWhiteSpaces($expected), $this->removeExtraWhiteSpaces($query));
}
+ public function test_getSelectQuery_whenUnionOfSegmentsAreUsed()
+ {
+ $select = 'log_visit.*';
+ $from = 'log_visit';
+ $where = false;
+ $bind = array();
+
+ $segment = 'actionUrl=@myTestUrl';
+ $segment = new Segment($segment, $idSites = array());
+
+ $query = $segment->getSelectQuery($select, $from, $where, $bind);
+
+ $expected = array(
+ "sql" => " SELECT log_inner.* FROM (
+ SELECT log_visit.* FROM log_visit AS log_visit
+ LEFT JOIN log_link_visit_action AS log_link_visit_action
+ ON log_link_visit_action.idvisit = log_visit.idvisit
+ WHERE (( log_link_visit_action.idaction_url IN (SELECT idaction FROM log_action WHERE ( name LIKE CONCAT('%', ?, '%') AND type = 1 )) )
+ OR ( log_link_visit_action.idaction_url IN (SELECT idaction FROM log_action WHERE ( name LIKE CONCAT('%', ?, '%') AND type = 3 )) )
+ OR ( log_link_visit_action.idaction_url IN (SELECT idaction FROM log_action WHERE ( name LIKE CONCAT('%', ?, '%') AND type = 2 )) ) )
+ GROUP BY log_visit.idvisit ORDER BY NULL ) AS log_inner",
+ "bind" => array('myTestUrl', 'myTestUrl', 'myTestUrl'));
+
+ $this->assertEquals($this->removeExtraWhiteSpaces($expected), $this->removeExtraWhiteSpaces($query));
+ }
+
public function test_getSelectQuery_whenJoinConversionOnAction_segmentUsesPageUrl()
{
$this->insertPageUrlAsAction('example.com/anypage');
diff --git a/tests/PHPUnit/System/AutoSuggestAPITest.php b/tests/PHPUnit/System/AutoSuggestAPITest.php
index 2ec2900f5e..9ab0023c2f 100644
--- a/tests/PHPUnit/System/AutoSuggestAPITest.php
+++ b/tests/PHPUnit/System/AutoSuggestAPITest.php
@@ -17,7 +17,6 @@ use Piwik\Plugins\CustomVariables\Columns\CustomVariableValue;
use Piwik\Plugins\CustomVariables\Model;
use Piwik\Tests\Framework\TestCase\SystemTestCase;
use Piwik\Tests\Fixtures\ManyVisitsWithGeoIP;
-use Piwik\Tests\Framework\Fixture;
use Piwik\Tracker\Cache;
/**
diff --git a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentContainsTest.php b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentContainsTest.php
index 92a4f2dde2..bad8cc45b3 100755
--- a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentContainsTest.php
+++ b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentContainsTest.php
@@ -48,6 +48,13 @@ class TwoVisitsWithCustomVariablesSegmentContainsTest extends SystemTestCase
array("pageTitle=@Profile pa", '_SegmentPageTitleContains', $api),
array("pageUrl!@user/profile", '_SegmentPageUrlExcludes', $api),
array("pageTitle!@Profile pa", '_SegmentPageTitleExcludes', $api),
+ // starts with
+ array('pageUrl=^example.org/home', '_SegmentPageUrlStartsWith', array('Actions.getPageUrls')),
+ array('pageTitle=^Profile pa', '_SegmentPageTitleStartsWith', array('Actions.getPageTitles')),
+
+ // ends with
+ array('pageUrl=$er/profile', '_SegmentPageUrlEndsWith', array('Actions.getPageUrls')),
+ array('pageTitle=$page', '_SegmentPageTitleEndsWith', array('Actions.getPageTitles')),
);
foreach ($segmentsToTest as $segment) {
diff --git a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php
index 3667f7f65b..65ff528dc6 100755
--- a/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php
+++ b/tests/PHPUnit/System/TwoVisitsWithCustomVariablesSegmentMatchNONETest.php
@@ -67,7 +67,7 @@ class TwoVisitsWithCustomVariablesSegmentMatchNONETest extends SystemTestCase
$matchNone = $segment . '!=' . $value;
// deviceType != campaign matches ALL visits, but we want to match None
- if($segment == 'deviceType') {
+ if ($segment == 'deviceType') {
$matchNone = $segment . '==car%20browser';
}
$segmentExpression[] = $matchNone;
diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionUrl__API.getSuggestedValuesForSegment.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionUrl__API.getSuggestedValuesForSegment.xml
new file mode 100644
index 0000000000..2e03969e6d
--- /dev/null
+++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionUrl__API.getSuggestedValuesForSegment.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<result>
+ <row>http://piwik.net/grue/lair</row>
+ <row>http://piwik.net/space/quest/iv</row>
+ <row>http://example-outlink.org/1.html</row>
+ <row>http://example.org/path/file1.zip</row>
+ <row>http://example.org/path/file0.zip</row>
+ <row>http://example-outlink.org/0.html</row>
+ <row>http://example.org/path/file2.zip</row>
+ <row>http://example.org/path/file3.zip</row>
+ <row>http://example-outlink.org/3.html</row>
+ <row>http://example-outlink.org/2.html</row>
+ <row>http://example.org/path/file4.zip</row>
+ <row>http://example.org/path/file5.zip</row>
+ <row>http://example.org/path/file8.zip</row>
+ <row>http://example-outlink.org/6.html</row>
+ <row>http://example-outlink.org/7.html</row>
+ <row>http://example-outlink.org/5.html</row>
+ <row>http://example-outlink.org/4.html</row>
+ <row>http://example.org/path/file7.zip</row>
+ <row>http://example-outlink.org/8.html</row>
+ <row>http://example.org/path/file6.zip</row>
+</result> \ No newline at end of file
diff --git a/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionUrl__VisitsSummary.get_range.xml b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionUrl__VisitsSummary.get_range.xml
new file mode 100644
index 0000000000..7ace3fcbe7
--- /dev/null
+++ b/tests/PHPUnit/System/expected/test_AutoSuggestAPITest_actionUrl__VisitsSummary.get_range.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<result>
+ <nb_visits>18</nb_visits>
+ <nb_actions>18</nb_actions>
+ <nb_visits_converted>18</nb_visits_converted>
+ <bounce_count>18</bounce_count>
+ <sum_visit_length>0</sum_visit_length>
+ <max_actions>1</max_actions>
+ <bounce_rate>100%</bounce_rate>
+ <nb_actions_per_visit>1</nb_actions_per_visit>
+ <avg_time_on_site>0</avg_time_on_site>
+</result> \ No newline at end of file
diff --git a/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml b/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml
index a8376a8758..017837d9a8 100644
--- a/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml
+++ b/tests/PHPUnit/System/expected/test_apiGetReportMetadata__API.getSegmentsMetadata.xml
@@ -416,6 +416,17 @@
<row>
<type>dimension</type>
<category>Actions</category>
+ <name>Action URL</name>
+ <segment>actionUrl</segment>
+ <unionOfSegments>
+ <row>pageUrl</row>
+ <row>downloadUrl</row>
+ <row>outlinkUrl</row>
+ </unionOfSegments>
+ </row>
+ <row>
+ <type>dimension</type>
+ <category>Actions</category>
<name>Clicked URL</name>
<segment>outlinkUrl</segment>
</row>
diff --git a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageTitleEndsWith__Actions.getPageTitles_day.xml b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageTitleEndsWith__Actions.getPageTitles_day.xml
new file mode 100644
index 0000000000..38eb716dff
--- /dev/null
+++ b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageTitleEndsWith__Actions.getPageTitles_day.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<result>
+ <row>
+ <label> Homepage</label>
+ <nb_visits>2</nb_visits>
+ <nb_uniq_visitors>2</nb_uniq_visitors>
+ <nb_hits>2</nb_hits>
+ <sum_time_spent>360</sum_time_spent>
+ <entry_nb_uniq_visitors>1</entry_nb_uniq_visitors>
+ <entry_nb_visits>1</entry_nb_visits>
+ <entry_nb_actions>3</entry_nb_actions>
+ <entry_sum_visit_length>364</entry_sum_visit_length>
+ <entry_bounce_count>0</entry_bounce_count>
+ <exit_nb_uniq_visitors>1</exit_nb_uniq_visitors>
+ <exit_nb_visits>1</exit_nb_visits>
+ <avg_time_on_page>180</avg_time_on_page>
+ <bounce_rate>0%</bounce_rate>
+ <exit_rate>50%</exit_rate>
+ </row>
+ <row>
+ <label> Profile page</label>
+ <nb_visits>1</nb_visits>
+ <nb_uniq_visitors>1</nb_uniq_visitors>
+ <nb_hits>1</nb_hits>
+ <sum_time_spent>0</sum_time_spent>
+ <avg_time_on_page>0</avg_time_on_page>
+ <bounce_rate>0%</bounce_rate>
+ <exit_rate>0%</exit_rate>
+ </row>
+</result> \ No newline at end of file
diff --git a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageTitleStartsWith__Actions.getPageTitles_day.xml b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageTitleStartsWith__Actions.getPageTitles_day.xml
new file mode 100644
index 0000000000..7cfe228274
--- /dev/null
+++ b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageTitleStartsWith__Actions.getPageTitles_day.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<result>
+ <row>
+ <label> Profile page</label>
+ <nb_visits>1</nb_visits>
+ <nb_uniq_visitors>1</nb_uniq_visitors>
+ <nb_hits>1</nb_hits>
+ <sum_time_spent>0</sum_time_spent>
+ <avg_time_on_page>0</avg_time_on_page>
+ <bounce_rate>0%</bounce_rate>
+ <exit_rate>0%</exit_rate>
+ </row>
+ <row>
+ <label> Profile page for user *_)%</label>
+ <nb_visits>1</nb_visits>
+ <nb_uniq_visitors>1</nb_uniq_visitors>
+ <nb_hits>1</nb_hits>
+ <sum_time_spent>0</sum_time_spent>
+ <exit_nb_uniq_visitors>1</exit_nb_uniq_visitors>
+ <exit_nb_visits>1</exit_nb_visits>
+ <avg_time_on_page>0</avg_time_on_page>
+ <bounce_rate>0%</bounce_rate>
+ <exit_rate>100%</exit_rate>
+ </row>
+</result> \ No newline at end of file
diff --git a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageUrlEndsWith__Actions.getPageUrls_day.xml b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageUrlEndsWith__Actions.getPageUrls_day.xml
new file mode 100644
index 0000000000..c64e18155a
--- /dev/null
+++ b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageUrlEndsWith__Actions.getPageUrls_day.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<result>
+ <row>
+ <label>user</label>
+ <nb_visits>1</nb_visits>
+ <nb_hits>2</nb_hits>
+ <sum_time_spent>0</sum_time_spent>
+ <exit_nb_visits>1</exit_nb_visits>
+ <avg_time_on_page>0</avg_time_on_page>
+ <bounce_rate>0%</bounce_rate>
+ <exit_rate>100%</exit_rate>
+ <subtable>
+ <row>
+ <label>/profile</label>
+ <nb_visits>1</nb_visits>
+ <nb_uniq_visitors>1</nb_uniq_visitors>
+ <nb_hits>2</nb_hits>
+ <sum_time_spent>0</sum_time_spent>
+ <exit_nb_uniq_visitors>1</exit_nb_uniq_visitors>
+ <exit_nb_visits>1</exit_nb_visits>
+ <avg_time_on_page>0</avg_time_on_page>
+ <bounce_rate>0%</bounce_rate>
+ <exit_rate>100%</exit_rate>
+ <url>http://example.org/user/profile</url>
+ </row>
+ </subtable>
+ </row>
+</result> \ No newline at end of file
diff --git a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageUrlStartsWith__Actions.getPageUrls_day.xml b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageUrlStartsWith__Actions.getPageUrls_day.xml
new file mode 100644
index 0000000000..21450c0dd4
--- /dev/null
+++ b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_SegmentPageUrlStartsWith__Actions.getPageUrls_day.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<result>
+ <row>
+ <label>/homepage</label>
+ <nb_visits>2</nb_visits>
+ <nb_uniq_visitors>2</nb_uniq_visitors>
+ <nb_hits>2</nb_hits>
+ <sum_time_spent>0</sum_time_spent>
+ <entry_nb_uniq_visitors>1</entry_nb_uniq_visitors>
+ <entry_nb_visits>1</entry_nb_visits>
+ <entry_nb_actions>3</entry_nb_actions>
+ <entry_sum_visit_length>364</entry_sum_visit_length>
+ <entry_bounce_count>0</entry_bounce_count>
+ <exit_nb_uniq_visitors>1</exit_nb_uniq_visitors>
+ <exit_nb_visits>1</exit_nb_visits>
+ <avg_time_on_page>0</avg_time_on_page>
+ <bounce_rate>0%</bounce_rate>
+ <exit_rate>50%</exit_rate>
+ <url>http://example.org/homepage</url>
+ <segment>pageUrl==http%3A%2F%2Fexample.org%2Fhomepage</segment>
+ </row>
+</result> \ No newline at end of file
diff --git a/tests/PHPUnit/Unit/Segment/SegmentExpressionTest.php b/tests/PHPUnit/Unit/Segment/SegmentExpressionTest.php
index 6d9dcc67b1..71e64863c1 100644
--- a/tests/PHPUnit/Unit/Segment/SegmentExpressionTest.php
+++ b/tests/PHPUnit/Unit/Segment/SegmentExpressionTest.php
@@ -72,6 +72,7 @@ class SegmentExpressionTest extends \PHPUnit_Framework_TestCase
array('A==B,C==D', array('where' => " (A = ? OR C = ? )", 'bind' => array('B', 'D'))),
array('A!=B;C==D', array('where' => " ( A IS NULL OR A <> ? ) AND C = ? ", 'bind' => array('B', 'D'))),
array('A!=B;C==D,E!=Hello World!=', array('where' => " ( A IS NULL OR A <> ? ) AND (C = ? OR ( E IS NULL OR E <> ? ) )", 'bind' => array('B', 'D', 'Hello World!='))),
+ array('A=@B;C=$D', array('where' => " A LIKE ? AND C LIKE ? ", 'bind' => array('%B%', '%D'))),
array('A>B', array('where' => " A > ? ", 'bind' => array('B'))),
array('A<B', array('where' => " A < ? ", 'bind' => array('B'))),
@@ -83,6 +84,8 @@ class SegmentExpressionTest extends \PHPUnit_Framework_TestCase
array('A=@B_', array('where' => " A LIKE ? ", 'bind' => array('%B\_%'))),
array('A!@B%', array('where' => " ( A IS NULL OR A NOT LIKE ? ) ", 'bind' => array('%B\%%'))),
+ array('A=$B%', array('where' => " A LIKE ? ", 'bind' => array('%B\%'))),
+ array('A=^B%', array('where' => " A LIKE ? ", 'bind' => array('B\%%'))),
);
}