File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ protected function fetchIdentities(array $data): array
8585 // Map our users by ID to make assigning simpler
8686 $ mappedUsers = [];
8787 $ users = $ data ['singleton ' ]
88- ? $ data
88+ ? [ $ data[ ' data ' ]]
8989 : $ data ['data ' ];
9090
9191 foreach ($ users as $ user ) {
@@ -100,7 +100,7 @@ protected function fetchIdentities(array $data): array
100100 $ mappedUsers [$ id ->user_id ]->identities = $ array ;
101101 }
102102
103- $ data ['data ' ] = $ mappedUsers ;
103+ $ data ['data ' ] = $ data [ ' singleton ' ] ? $ mappedUsers [ $ id -> user_id ] : $ mappedUsers ;
104104
105105 return $ data ;
106106 }
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ public function testGetIdentitiesByType(): void
5353 $ this ->assertEmpty ($ this ->user ->getIdentities ('foo ' ));
5454 }
5555
56- public function testModelWithIdentities (): void
56+ public function testModelfindAllWithIdentities (): void
5757 {
5858 fake (UserModel::class);
5959 fake (UserIdentityModel::class, ['user_id ' => $ this ->user ->id , 'type ' => 'password ' ]);
@@ -67,6 +67,18 @@ public function testModelWithIdentities(): void
6767 $ this ->assertCount (2 , $ identities );
6868 }
6969
70+ public function testModelfindByIdWithIdentities (): void
71+ {
72+ fake (UserModel::class);
73+ fake (UserIdentityModel::class, ['user_id ' => $ this ->user ->id , 'type ' => 'password ' ]);
74+ fake (UserIdentityModel::class, ['user_id ' => $ this ->user ->id , 'type ' => 'access_token ' ]);
75+
76+ // Grab the user again, using the model's identity helper
77+ $ user = model (UserModel::class)->withIdentities ()->findById (1 );
78+
79+ $ this ->assertCount (2 , $ user ->identities );
80+ }
81+
7082 public function testLastLogin (): void
7183 {
7284 fake (
You can’t perform that action at this time.
0 commit comments