@@ -216,6 +216,26 @@ public function testSelecting()
216216 $ this ->assertEquals (1 , $ this ->object ->query ('DROP TABLE unit_test ' ));
217217 }
218218
219+ public function testWhereGroup ()
220+ {
221+ $ this ->assertTrue ($ this ->object ->connect ('sqlite: ' . self ::TEST_SQLITE_DB , '' , '' , array (), true ));
222+ $ this ->object ->query ('CREATE TABLE unit_test(id integer, test_key varchar(50), active tinyint(1), PRIMARY KEY (ID)) ' );
223+ $ this ->object ->insert ('unit_test ' , array ('id ' => '1 ' , 'test_key ' => 'testing 1 ' , 'active ' => 1 ));
224+ $ this ->object ->insert ('unit_test ' , array ('id ' => '2 ' , 'test_key ' => 'testing 2 ' , 'active ' => 0 ));
225+ $ this ->object ->insert ('unit_test ' , array ('id ' => '3 ' , 'test_key ' => 'testing 3 ' , 'active ' => 1 ));
226+ $ this ->object ->insert ('unit_test ' , array ('id ' => '4 ' , 'test_key ' => 'testing 4 ' , 'active ' => 1 ));
227+
228+ $ result = $ this ->object ->selecting ('unit_test ' , '* ' , where (eq ('active ' , '1 ' ), whereGroup (like ('test_key ' , '%1% ' , _OR ), like ('test_key ' , '%3% ' , _OR ))));
229+ $ i = 1 ;
230+ foreach ($ result as $ row ) {
231+ $ this ->assertEquals ($ i , $ row ->id );
232+ $ this ->assertEquals ('testing ' . $ i , $ row ->test_key );
233+ $ i = $ i + 2 ;
234+ }
235+
236+ $ this ->assertEquals (0 , $ this ->object ->query ('DROP TABLE unit_test ' ));
237+ }
238+
219239 public function testJoins ()
220240 {
221241 $ this ->assertTrue ($ this ->object ->connect ('sqlite: ' . self ::TEST_SQLITE_DB , '' , '' , array (), true ));
0 commit comments