Skip to content

Commit 169494c

Browse files
committed
Add tests
1 parent 4e17932 commit 169494c

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

tests/Unit/Models/ModelHasManyTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function test_only_related_with_many_relation_object_classes()
227227
{
228228
// Scopes are wrapped in their own AndGroup for isolation
229229
$this->assertEquals(
230-
'(&(&(|(objectclass=top)(objectclass=person)(objectclass=organizationalperson)(objectclass=user))(|(objectclass=top)(objectclass=group))))',
230+
'(&(|(objectclass=top)(objectclass=person)(objectclass=organizationalperson)(objectclass=user))(|(objectclass=top)(objectclass=group)))',
231231
(new ModelHasManyStubWithManyRelated)->relation()->onlyRelated()->getQuery()->getUnescapedQuery()
232232
);
233233
}

tests/Unit/Models/ModelQueryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function test_new_queries_apply_object_class_scopes()
8282

8383
// Scopes are wrapped in their own AndGroup for isolation
8484
$this->assertEquals(
85-
'(&(&(objectclass=foo)(objectclass=bar)(objectclass=baz)))',
85+
'(&(objectclass=foo)(objectclass=bar)(objectclass=baz))',
8686
ModelWithObjectClassStub::query()->getUnescapedQuery()
8787
);
8888
}

tests/Unit/Models/ModelScopeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function test_scopes_remain_enforced_with_complex_queries()
167167
{
168168
// The scope (foo=bar) must always be present and enforced at the root AND level
169169
$this->assertEquals(
170-
'(&(|(name=\4a\6f\68\6e)(name=\4a\61\6e\65))(active=\74\72\75\65)(&(foo=bar)))',
170+
'(&(&(|(name=\4a\6f\68\6e)(name=\4a\61\6e\65))(active=\74\72\75\65))(&(foo=bar)))',
171171
ModelWithGlobalScopeTestStub::query()
172172
->where('name', '=', 'John')
173173
->orWhere('name', '=', 'Jane')

tests/Unit/Query/Model/ActiveDirectoryBuilderTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,28 @@ public function test_add_select_with_variadic_arguments()
165165
$this->assertContains('mail', $selects);
166166
$this->assertContains('objectguid', $selects);
167167
}
168+
169+
public function test_or_filter_extracts_filters_from_nested_query()
170+
{
171+
$b = $this->newBuilder();
172+
173+
$query = $b->orFilter(function ($query) {
174+
$query->whereEquals('foo', '1');
175+
$query->whereEquals('foo', '2');
176+
})->getUnescapedQuery();
177+
178+
$this->assertEquals('(|(foo=1)(foo=2))', $query);
179+
}
180+
181+
public function test_and_filter_extracts_filters_from_nested_query()
182+
{
183+
$b = $this->newBuilder();
184+
185+
$query = $b->andFilter(function ($query) {
186+
$query->whereEquals('foo', '1');
187+
$query->whereEquals('foo', '2');
188+
})->getUnescapedQuery();
189+
190+
$this->assertEquals('(&(foo=1)(foo=2))', $query);
191+
}
168192
}

0 commit comments

Comments
 (0)