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:
authormattab <matthieu.aubry@gmail.com>2013-05-12 10:09:22 +0400
committermattab <matthieu.aubry@gmail.com>2013-05-12 10:09:22 +0400
commitd89a08b8b27ef9a7293e9f8cf351bedbd838e2cb (patch)
tree0aa6a2e2233d8a3b77deefe97fb3e142592003a4 /tests
parent263892f231da5f6e998342aef02f33aa7edf8622 (diff)
Fixes #3932
* you can now write browserCode==ff;referrerKeyword!= to select all visitors using firefox and that have a keyword set * or you can write referrerKeyword==;browserCode==ff to select all visitors using firefox and that did not have any keyword set Also fixes #3933 Refs #2135 * fixing last bugs with segment selector encoding (working on chrome + FF + opera) - I 'hope' it will work on iE...
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/Core/SegmentExpressionTest.php13
-rw-r--r--tests/PHPUnit/Core/SegmentTest.php25
2 files changed, 29 insertions, 9 deletions
diff --git a/tests/PHPUnit/Core/SegmentExpressionTest.php b/tests/PHPUnit/Core/SegmentExpressionTest.php
index ea53e5d049..afbfa23854 100644
--- a/tests/PHPUnit/Core/SegmentExpressionTest.php
+++ b/tests/PHPUnit/Core/SegmentExpressionTest.php
@@ -60,10 +60,10 @@ class SegmentExpressionTest extends PHPUnit_Framework_TestCase
return array(
array('A==B%', array('where' => " A = ? ", 'bind' => array('B%'))),
array('ABCDEF====B===', array('where' => " ABCDEF = ? ", 'bind' => array('==B==='))),
- array('A===B;CDEF!=C!=', array('where' => " A = ? AND CDEF <> ? ", 'bind' => array('=B', 'C!='))),
+ array('A===B;CDEF!=C!=', array('where' => " A = ? AND ( CDEF IS NULL OR CDEF <> ? ) ", 'bind' => array('=B', 'C!='))),
array('A==B,C==D', array('where' => " (A = ? OR C = ? )", 'bind' => array('B', 'D'))),
- array('A!=B;C==D', array('where' => " A <> ? AND C = ? ", 'bind' => array('B', 'D'))),
- array('A!=B;C==D,E!=Hello World!=', array('where' => " A <> ? AND (C = ? OR E <> ? )", 'bind' => array('B', 'D', 'Hello World!='))),
+ 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', array('where' => " A > ? ", 'bind' => array('B'))),
array('A<B', array('where' => " A < ? ", 'bind' => array('B'))),
@@ -74,7 +74,7 @@ class SegmentExpressionTest extends PHPUnit_Framework_TestCase
array('A>=B;C>=D,E<w_ow great!', array('where' => " A >= ? AND (C >= ? OR E < ? )", 'bind' => array('B', 'D', 'w_ow great!'))),
array('A=@B_', array('where' => " A LIKE ? ", 'bind' => array('%B\_%'))),
- array('A!@B%', array('where' => " A NOT LIKE ? ", 'bind' => array('%B\%%'))),
+ array('A!@B%', array('where' => " ( A IS NULL OR A NOT LIKE ? ) ", 'bind' => array('%B\%%'))),
);
}
@@ -107,8 +107,7 @@ class SegmentExpressionTest extends PHPUnit_Framework_TestCase
array(',;,'),
array(','),
array(',,'),
- array('==='),
- array('!=')
+ array('!='),
);
}
@@ -126,6 +125,6 @@ class SegmentExpressionTest extends PHPUnit_Framework_TestCase
} catch (Exception $e) {
return;
}
- $this->fail('Expected exception not raised');
+ $this->fail('Expected exception not raised for:' . var_export($segment->getSql(), true));
}
}
diff --git a/tests/PHPUnit/Core/SegmentTest.php b/tests/PHPUnit/Core/SegmentTest.php
index 35da2a58a3..c007cc9d20 100644
--- a/tests/PHPUnit/Core/SegmentTest.php
+++ b/tests/PHPUnit/Core/SegmentTest.php
@@ -55,7 +55,7 @@ class SegmentTest extends PHPUnit_Framework_TestCase
// AND, with 2 values rewrites
array('countryCode==a;visitorType!=returning;visitorType==new', array(
- 'where' => ' log_visit.location_country = ? AND log_visit.visitor_returning <> ? AND log_visit.visitor_returning = ? ',
+ 'where' => ' log_visit.location_country = ? AND ( log_visit.visitor_returning IS NULL OR log_visit.visitor_returning <> ? ) AND log_visit.visitor_returning = ? ',
'bind' => array('a', '1', '0'))),
// OR, with 2 value rewrites
@@ -63,6 +63,27 @@ class SegmentTest extends PHPUnit_Framework_TestCase
'where' => ' (log_visit.referer_type = ? OR log_visit.referer_type = ? )',
'bind' => array(Piwik_Common::REFERER_TYPE_SEARCH_ENGINE,
Piwik_Common::REFERER_TYPE_DIRECT_ENTRY))),
+
+ // IS NOT NULL
+ array('browserCode==ff;referrerKeyword!=', array(
+ 'where' => ' log_visit.config_browser_name = ? AND ( log_visit.referer_keyword IS NOT NULL AND (log_visit.referer_keyword <> \'\' OR log_visit.referer_keyword = 0) ) ',
+ 'bind' => array('ff')
+ )),
+ array('referrerKeyword!=,browserCode==ff', array(
+ 'where' => ' (( log_visit.referer_keyword IS NOT NULL AND (log_visit.referer_keyword <> \'\' OR log_visit.referer_keyword = 0) ) OR log_visit.config_browser_name = ? )',
+ 'bind' => array('ff')
+ )),
+
+ // IS NULL
+ array('browserCode==ff;referrerKeyword==', array(
+ 'where' => ' log_visit.config_browser_name = ? AND ( log_visit.referer_keyword IS NULL OR log_visit.referer_keyword = \'\' ) ',
+ 'bind' => array('ff')
+ )),
+ array('referrerKeyword==,browserCode==ff', array(
+ 'where' => ' (( log_visit.referer_keyword IS NULL OR log_visit.referer_keyword = \'\' ) OR log_visit.config_browser_name = ? )',
+ 'bind' => array('ff')
+ )),
+
);
}
@@ -259,7 +280,7 @@ class SegmentTest extends PHPUnit_Framework_TestCase
WHERE
( log_conversion.idvisit = ? )
AND
- ( log_conversion.idgoal <> ? AND log_link_visit_action.custom_var_k1 = ? AND log_conversion.idgoal = ? )",
+ ( ( log_conversion.idgoal IS NULL OR log_conversion.idgoal <> ? ) AND log_link_visit_action.custom_var_k1 = ? AND log_conversion.idgoal = ? )",
"bind" => array(1, 2, 'Test', 1));
$this->assertEquals($this->_filterWhitsSpaces($expected), $this->_filterWhitsSpaces($query));