Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit e540d3f

Browse files
committed
Fixed tests
1 parent 7cc16a8 commit e540d3f

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

tests/UserResolverTest.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,22 @@ public function scopes_are_applied_when_query_is_called()
6666

6767
$schema = m::mock(SchemaInterface::class);
6868

69-
$schema->shouldReceive('userPrincipalName')->once()->withNoArgs()->andReturn('userprincipalname');
69+
$schema
70+
->shouldReceive('userPrincipalName')->once()->withNoArgs()->andReturn('userprincipalname')
71+
->shouldReceive('objectGuid')->once()->withNoArgs()->andReturn('objectguid');
7072

7173
$builder = m::mock(Builder::class);
7274

73-
$builder->shouldReceive('whereHas')->once()->withArgs(['userprincipalname'])
74-
->shouldReceive('getSchema')->once()->andReturn($schema);
75+
$builder
76+
->shouldReceive('whereHas')->once()->withArgs(['userprincipalname'])->andReturnSelf()
77+
->shouldReceive('getSelects')->once()->andReturn(['*'])
78+
->shouldReceive('select')->with(['*', 'objectguid'])->andReturnSelf()
79+
->shouldReceive('getSchema')->twice()->andReturn($schema);
7580

7681
$provider = m::mock(ProviderInterface::class);
7782

78-
$provider->shouldReceive('search')->once()->andReturn($provider)
83+
$provider
84+
->shouldReceive('search')->once()->andReturn($provider)
7985
->shouldReceive('users')->once()->andReturn($builder);
8086

8187
$ad = m::mock(AdldapInterface::class);
@@ -104,14 +110,23 @@ public function connection_is_set_when_retrieving_provider()
104110
/** @test */
105111
public function by_credentials_retrieves_alternate_username_attribute_depending_on_user_provider()
106112
{
113+
$schema = m::mock(SchemaInterface::class);
114+
115+
$schema->shouldReceive('objectGuid')->once()->withNoArgs()->andReturn('objectguid');
116+
107117
$query = m::mock(Builder::class);
108118

109-
$query->shouldReceive('whereEquals')->once()->with('userprincipalname', 'jdoe')->andReturnSelf()
119+
$query
120+
->shouldReceive('whereEquals')->once()->with('userprincipalname', 'jdoe')->andReturnSelf()
121+
->shouldReceive('getSelects')->once()->andReturn(['*'])
122+
->shouldReceive('select')->with(['*', 'objectguid'])->andReturnSelf()
123+
->shouldReceive('getSchema')->once()->andReturn($schema)
110124
->shouldReceive('first')->andReturnNull();
111125

112126
$ldapProvider = m::mock(ProviderInterface::class);
113127

114-
$ldapProvider->shouldReceive('search')->once()->andReturnSelf()
128+
$ldapProvider
129+
->shouldReceive('search')->once()->andReturnSelf()
115130
->shouldReceive('users')->once()->andReturn($query);
116131

117132
$ad = m::mock(AdldapInterface::class);

0 commit comments

Comments
 (0)