diff options
author | Geolim4 <contact@geolim4.com> | 2014-08-08 15:06:12 +0200 |
---|---|---|
committer | Geolim4 <contact@geolim4.com> | 2014-08-08 16:40:33 +0200 |
commit | 6b60153ab4ac036bcd4eaaa90806d9898fc1e9a2 (patch) | |
tree | d378a9a0aa46968a08a0f20dcbbe4b4e2c049f3a /tests/dbal/select_test.php | |
parent | f6da2661091a9f068956a23df7e70450cec9ee74 (diff) | |
download | forums-6b60153ab4ac036bcd4eaaa90806d9898fc1e9a2.tar forums-6b60153ab4ac036bcd4eaaa90806d9898fc1e9a2.tar.gz forums-6b60153ab4ac036bcd4eaaa90806d9898fc1e9a2.tar.bz2 forums-6b60153ab4ac036bcd4eaaa90806d9898fc1e9a2.tar.xz forums-6b60153ab4ac036bcd4eaaa90806d9898fc1e9a2.zip |
[ticket/12671] Possibility to use NOT LIKE expression
PHPBB3-12671
Diffstat (limited to 'tests/dbal/select_test.php')
-rw-r--r-- | tests/dbal/select_test.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/dbal/select_test.php b/tests/dbal/select_test.php index e480716a49..ce07d7d0fb 100644 --- a/tests/dbal/select_test.php +++ b/tests/dbal/select_test.php @@ -233,6 +233,48 @@ class phpbb_dbal_select_test extends phpbb_database_test_case $db->sql_freeresult($result); } + public function not_like_expression_data() + { + // * = any_char; # = one_char + return array( + array('barfoo', array(array('username_clean' => 'bertie'), + array('username_clean' => 'foobar'))), + array('bar', array(array('username_clean' => 'bertie'),)), + array('bar*', array(array('username_clean' => 'bertie'), + array('username_clean' => 'foobar'))), + array('*bar*', array(array('username_clean' => 'bertie'))), + array('b*r', array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'))), + array('b*e', array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'))), + array('#b*e', array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'))), + array('b####e', array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'))), + ); + } + + /** + * @dataProvider not_like_expression_data + */ + public function test_not_like_expression($like_expression, $expected) + { + $db = $this->new_dbal(); + + $like_expression = str_replace('*', $db->get_any_char(), $like_expression); + $like_expression = str_replace('#', $db->get_one_char(), $like_expression); + $where = ($like_expression) ? 'username_clean ' . $db->sql_not_like_expression($like_expression) : ''; + + $result = $db->sql_query('SELECT username_clean + FROM phpbb_users + ' . (($where) ? ' WHERE ' . $where : '') . ' + ORDER BY user_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + + $db->sql_freeresult($result); + } + public function in_set_data() { return array( |