@@ -589,6 +589,34 @@ public function test_built_where_and_or_wheres()
589589 $ this ->assertEquals ('(|(field=value)(or=value)) ' , $ b ->getUnescapedQuery ());
590590 }
591591
592+ public function test_single_where_with_multiple_or_wheres_creates_single_or_filter ()
593+ {
594+ // This test verifies the fix for GitHub issue #606
595+ // https://github.com/DirectoryTree/LdapRecord-Laravel/issues/606
596+ $ b = $ this ->newBuilder ()
597+ ->where ('memberof ' , '= ' , 'cn=Group1 ' )
598+ ->orWhere ('memberof ' , '= ' , 'cn=Group2 ' )
599+ ->orWhere ('memberof ' , '= ' , 'cn=Group3 ' );
600+
601+ $ this ->assertEquals (
602+ '(|(memberof=cn=Group1)(memberof=cn=Group2)(memberof=cn=Group3)) ' ,
603+ $ b ->getUnescapedQuery ()
604+ );
605+ }
606+
607+ public function test_single_where_with_single_or_where_creates_single_or_filter ()
608+ {
609+ // This test verifies that the existing behavior for 1 where + 1 orWhere is preserved
610+ $ b = $ this ->newBuilder ()
611+ ->where ('field ' , '= ' , 'value1 ' )
612+ ->orWhere ('field ' , '= ' , 'value2 ' );
613+
614+ $ this ->assertEquals (
615+ '(|(field=value1)(field=value2)) ' ,
616+ $ b ->getUnescapedQuery ()
617+ );
618+ }
619+
592620 public function test_built_where_has ()
593621 {
594622 $ b = $ this ->newBuilder ();
0 commit comments