@@ -29,6 +29,24 @@ public function test_where_member_of()
2929 $ this ->assertEquals ('(memberof=cn=Accounting,dc=org,dc=acme) ' , $ b ->getUnescapedQuery ());
3030 }
3131
32+ public function test_where_member_of_substitutes_base_dn ()
33+ {
34+ $ b = $ this ->newBuilder ();
35+ $ b ->setBaseDn ('dc=org,dc=acme ' );
36+ $ b ->whereMemberOf ('cn=Accounting,{base} ' );
37+ $ where = $ b ->filters ['and ' ][0 ];
38+ $ this ->assertEquals ('memberof ' , $ where ['field ' ]);
39+ $ this ->assertEquals ('= ' , $ where ['operator ' ]);
40+ $ this ->assertEquals (
41+ '\63\6e\3d\41\63\63\6f\75\6e\74\69\6e\67\2c\64\63\3d\6f\72\67\2c\64\63\3d\61\63\6d\65 ' ,
42+ $ where ['value ' ]
43+ );
44+ $ this ->assertEquals (
45+ '(memberof=cn=Accounting,dc=org,dc=acme) ' ,
46+ $ b ->getUnescapedQuery ()
47+ );
48+ }
49+
3250 public function test_where_member_of_nested ()
3351 {
3452 $ b = $ this ->newBuilder ();
@@ -43,6 +61,24 @@ public function test_where_member_of_nested()
4361 $ this ->assertEquals ('(memberof:1.2.840.113556.1.4.1941:=cn=Accounting,dc=org,dc=acme) ' , $ b ->getUnescapedQuery ());
4462 }
4563
64+ public function test_where_member_of_nested_substitutes_base_dn ()
65+ {
66+ $ b = $ this ->newBuilder ();
67+ $ b ->setBaseDn ('dc=org,dc=acme ' );
68+ $ b ->whereMemberOf ('cn=Accounting,{base} ' , $ nested = true );
69+ $ where = $ b ->filters ['and ' ][0 ];
70+ $ this ->assertEquals ('memberof:1.2.840.113556.1.4.1941: ' , $ where ['field ' ]);
71+ $ this ->assertEquals ('= ' , $ where ['operator ' ]);
72+ $ this ->assertEquals (
73+ '\63\6e\3d\41\63\63\6f\75\6e\74\69\6e\67\2c\64\63\3d\6f\72\67\2c\64\63\3d\61\63\6d\65 ' ,
74+ $ where ['value ' ]
75+ );
76+ $ this ->assertEquals (
77+ '(memberof:1.2.840.113556.1.4.1941:=cn=Accounting,dc=org,dc=acme) ' ,
78+ $ b ->getUnescapedQuery ()
79+ );
80+ }
81+
4682 public function test_or_where_member_of ()
4783 {
4884 $ b = $ this ->newBuilder ();
@@ -61,6 +97,25 @@ public function test_or_where_member_of()
6197 );
6298 }
6399
100+ public function test_or_where_member_of_substitutes_base_dn ()
101+ {
102+ $ b = $ this ->newBuilder ();
103+ $ b ->setBaseDn ('dc=org,dc=acme ' );
104+ $ b ->orWhereEquals ('cn ' , 'John Doe ' );
105+ $ b ->orWhereMemberOf ('cn=Accounting,{base} ' );
106+ $ where = $ b ->filters ['or ' ][1 ];
107+ $ this ->assertEquals ('memberof ' , $ where ['field ' ]);
108+ $ this ->assertEquals ('= ' , $ where ['operator ' ]);
109+ $ this ->assertEquals (
110+ '\63\6e\3d\41\63\63\6f\75\6e\74\69\6e\67\2c\64\63\3d\6f\72\67\2c\64\63\3d\61\63\6d\65 ' ,
111+ $ where ['value ' ]
112+ );
113+ $ this ->assertEquals (
114+ '(|(cn=John Doe)(memberof=cn=Accounting,dc=org,dc=acme)) ' ,
115+ $ b ->getUnescapedQuery ()
116+ );
117+ }
118+
64119 public function test_or_where_member_of_nested ()
65120 {
66121 $ b = $ this ->newBuilder ();
0 commit comments