@@ -62,7 +62,7 @@ protected function setUp(): void
6262
6363 $ logger = m::mock (LoggerInterface::class);
6464 $ logger ->shouldIgnoreMissing (); // Not going to verify every log message at this point
65- $ this ->deprovisionService = new DeprovisionService ( $ this ->pipeline , $ this -> eventRepo , $ this -> apiRepo , $ logger, $ this -> sraaRepo , $ this -> raListingRepo );
65+ $ this ->deprovisionService = $ this ->buildDeprovisionService ( $ logger );
6666 }
6767
6868 public function test_it_can_be_created (): void
@@ -112,6 +112,50 @@ public function test_deprovision_does_not_deprovision_when_user_is_not_found():
112112 $ this ->deprovisionService ->deprovision ('urn:collab:person:example.com:maynard_keenan ' );
113113 }
114114
115+ #[Group('api-bundle ' )]
116+ public function test_deprovision_logs_unknown_identity_when_not_found (): void
117+ {
118+ $ logger = m::mock (LoggerInterface::class);
119+ $ logger ->shouldReceive ('debug ' )->once ();
120+ $ logger ->shouldReceive ('notice ' )
121+ ->once ()
122+ ->with (m::on (static fn (string $ message ): bool => str_contains ($ message , 'was not found ' )));
123+
124+ $ deprovisionService = $ this ->buildDeprovisionService ($ logger );
125+
126+ $ this ->apiRepo
127+ ->shouldReceive ('findOneByNameId ' )
128+ ->with ('urn:collab:person:example.com:unknown_user ' )
129+ ->once ()
130+ ->andReturnNull ();
131+
132+ $ this ->pipeline ->shouldNotReceive ('process ' );
133+
134+ $ deprovisionService ->deprovision ('urn:collab:person:example.com:unknown_user ' );
135+ }
136+
137+ #[Group('api-bundle ' )]
138+ public function test_read_user_data_returns_empty_array_for_unknown_identity (): void
139+ {
140+ $ logger = m::mock (LoggerInterface::class);
141+ $ logger ->shouldReceive ('debug ' )->once ();
142+ $ logger ->shouldReceive ('notice ' )
143+ ->once ()
144+ ->with (m::on (static fn (string $ message ): bool => str_contains ($ message , 'was not found ' )));
145+
146+ $ deprovisionService = $ this ->buildDeprovisionService ($ logger );
147+
148+ $ this ->apiRepo
149+ ->shouldReceive ('findOneByNameId ' )
150+ ->with ('urn:collab:person:example.com:unknown_user ' )
151+ ->once ()
152+ ->andReturnNull ();
153+
154+ $ result = $ deprovisionService ->readUserData ('urn:collab:person:example.com:unknown_user ' );
155+
156+ $ this ->assertEmpty ($ result );
157+ }
158+
115159 public function test_deprovision_method_performs_the_right_to_be_forgotten_command (): void
116160 {
117161 $ identity = m::mock (Identity::class);
@@ -162,4 +206,16 @@ public function test_is_allowed_to_deprovision_user(): void
162206
163207 $ this ->deprovisionService ->assertIsAllowed ($ nameId );
164208 }
209+
210+ private function buildDeprovisionService (LoggerInterface $ logger ): DeprovisionService
211+ {
212+ return new DeprovisionService (
213+ $ this ->pipeline ,
214+ $ this ->eventRepo ,
215+ $ this ->apiRepo ,
216+ $ logger ,
217+ $ this ->sraaRepo ,
218+ $ this ->raListingRepo
219+ );
220+ }
165221}
0 commit comments