test: stop OuTreeServiceTest hitting a real LDAP server
CI / PHP 8.4 (push) Successful in 1m5s
Release image / image (push) Successful in 1m39s

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:
kzbkowskiandClaude Sonnet 5 committed 2026-09-10 09:24:15 +02:00
1 parent 2b970226fc
commit 3dae779724
1 file changed
+5 -1
+5 -1
View File
@@ -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');