test: stop OuTreeServiceTest hitting a real LDAP server
it_limits_tree_to_default_user_and_computer_ous only mocked OrganizationalUnit::query(); attachCounts() then called the real User/Computer query via countObjectsInOu(), which threw "Can't contact LDAP server" on any checkout whose .env points LDAP_HOSTS at an unreachable DC (i.e. every CI run since v1.0.0). Stub countObjectsInOu() on a partial mock, like the sibling test already does — the test only asserts tree shape, not counts. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JKT9p3bfP8RZesExdYCS52
This commit is contained in:
1 parent
2b970226fc
commit
3dae779724
1 file changed
+5
-1
@@ -114,7 +114,11 @@ class OuTreeServiceTest extends TestCase
|
||||
Mockery::mock('alias:\LdapRecord\Models\ActiveDirectory\OrganizationalUnit')
|
||||
->shouldReceive('query')->twice()->andReturn($query);
|
||||
|
||||
$service = new OuTreeService;
|
||||
// Ten test sprawdza wyłącznie kształt drzewa (ograniczenie do rootów +
|
||||
// zagnieżdżenie), nie liczniki - a countObjectsInOu() odpytałoby realny
|
||||
// LDAP. Podstawiamy 0.
|
||||
$service = Mockery::mock(OuTreeService::class)->makePartial()->shouldAllowMockingProtectedMethods();
|
||||
$service->shouldReceive('countObjectsInOu')->andReturn(0);
|
||||
|
||||
$userTree = $service->tree('users');
|
||||
$computerTree = $service->tree('computers');
|
||||
|
||||
Reference in new issue
Block a user