Skip to content

Commit 88999ff

Browse files
Merge pull request #134 from limosa-io/filter-multi-conditions
Add test for multi-condition filter combining criteria with AND #110
2 parents cdd0564 + 29b4611 commit 88999ff

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/FilterQueryTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,45 @@ public function testValuePathNegationMatchesRFCSection341(): void
6767
'Groups without the user should remain when using not(valuePath) filter.'
6868
);
6969
}
70+
71+
public function testMultiConditionFilterCombinesCriteriaWithAnd(): void
72+
{
73+
$matchingUser = factory(User::class)->create([
74+
'name' => 'te-matching-user',
75+
'formatted' => 'te matching formatted',
76+
'email' => '[email protected]',
77+
]);
78+
79+
$formattedOnlyUser = factory(User::class)->create([
80+
'name' => 'AlphaName',
81+
'formatted' => 'te formatted only',
82+
'email' => '[email protected]',
83+
]);
84+
85+
$userNameOnlyUser = factory(User::class)->create([
86+
'name' => 'te username only',
87+
'formatted' => 'AlphaDisplay',
88+
'email' => '[email protected]',
89+
]);
90+
91+
$filter = rawurlencode('name.formatted co "te" and userName co "te"');
92+
93+
$response = $this->get("/scim/v2/Users?filter={$filter}&count=200");
94+
$response->assertStatus(200);
95+
96+
$ids = collect($response->json('Resources'))->pluck('id');
97+
98+
$this->assertTrue(
99+
$ids->contains((string)$matchingUser->id),
100+
'Expected user that matches both conditions to be returned.'
101+
);
102+
$this->assertFalse(
103+
$ids->contains((string)$formattedOnlyUser->id),
104+
'User matching only the formatted condition should be excluded.'
105+
);
106+
$this->assertFalse(
107+
$ids->contains((string)$userNameOnlyUser->id),
108+
'User matching only the userName condition should be excluded.'
109+
);
110+
}
70111
}

0 commit comments

Comments
 (0)