@@ -786,6 +786,36 @@ public function test_nested_or_filter_with_where_equals()
786786 $ this ->assertEquals ('(|(foo=1)(foo=2)) ' , $ query );
787787 }
788788
789+ public function test_nested_or_filter_preserves_nested_and_filter_when_followed_by_where ()
790+ {
791+ $ b = $ this ->newBuilder ();
792+
793+ $ query = $ b ->orFilter (function ($ query ) {
794+ $ query ->andFilter (function ($ query ) {
795+ $ query ->whereStartsWith ('givenName ' , 'John ' );
796+ $ query ->whereStartsWith ('sn ' , 'Smith ' );
797+ });
798+ $ query ->where ('mail ' , '= ' , 'John Smith ' );
799+ })->getUnescapedQuery ();
800+
801+ $ this ->assertEquals ('(|(&(givenName=John*)(sn=Smith*))(mail=John Smith)) ' , $ query );
802+ }
803+
804+ public function test_nested_or_filter_preserves_nested_and_filter_when_preceded_by_where ()
805+ {
806+ $ b = $ this ->newBuilder ();
807+
808+ $ query = $ b ->orFilter (function ($ query ) {
809+ $ query ->where ('mail ' , '= ' , 'John Smith ' );
810+ $ query ->andFilter (function ($ query ) {
811+ $ query ->whereStartsWith ('givenName ' , 'John ' );
812+ $ query ->whereStartsWith ('sn ' , 'Smith ' );
813+ });
814+ })->getUnescapedQuery ();
815+
816+ $ this ->assertEquals ('(|(mail=John Smith)(&(givenName=John*)(sn=Smith*))) ' , $ query );
817+ }
818+
789819 public function test_nested_and_filter ()
790820 {
791821 $ b = $ this ->newBuilder ();
@@ -816,6 +846,19 @@ public function test_nested_not_filter()
816846 $ this ->assertEquals ('(!(&(one=one)(two=two))) ' , $ query );
817847 }
818848
849+ public function test_nested_and_filter_preserves_not_filter ()
850+ {
851+ $ b = $ this ->newBuilder ();
852+
853+ $ query = $ b ->andFilter (function ($ query ) {
854+ $ query ->notFilter (function ($ query ) {
855+ $ query ->whereEquals ('foo ' , 'bar ' );
856+ });
857+ })->getUnescapedQuery ();
858+
859+ $ this ->assertEquals ('(&(!(foo=bar))) ' , $ query );
860+ }
861+
819862 public function test_nested_filters ()
820863 {
821864 $ b = $ this ->newBuilder ();
0 commit comments