Skip to content

Commit 0ee0a85

Browse files
committed
refactor(test): modernize HttpRepositoryTest syntax
1 parent 01bcde4 commit 0ee0a85

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

tests/Infrastructure/Repository/HttpRepositoryTest.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,11 @@ public function testShouldDispatchEventOnSuccess(): void
228228
$dispatcher = $this->createMock(EventDispatcherInterface::class);
229229
$dispatcher->expects($this->once())
230230
->method('dispatch')
231-
->with($this->callback(function ($event) {
232-
return $event instanceof RequestExecutedEvent
233-
&& $event->method === 'POST'
234-
&& $event->uri === '/api'
235-
&& isset($event->options['json'])
236-
&& $event->message !== null;
237-
}));
231+
->with($this->callback(fn($event) => $event instanceof RequestExecutedEvent
232+
&& $event->method === 'POST'
233+
&& $event->uri === '/api'
234+
&& isset($event->options['json'])
235+
&& $event->message !== null));
238236

239237
$repository = new HttpRepositoryTestMock($clientFactory, $dispatcher);
240238
$repository->exposeRequest('POST', '/api', ['json' => ['key' => 'value']]);
@@ -261,12 +259,10 @@ public function testShouldDispatchEventOnFailure(): void
261259
$dispatcher = $this->createMock(EventDispatcherInterface::class);
262260
$dispatcher->expects($this->once())
263261
->method('dispatch')
264-
->with($this->callback(function ($event) {
265-
return $event instanceof RequestExecutedEvent
266-
&& $event->method === 'POST'
267-
&& $event->uri === '/api'
268-
&& $event->message !== null;
269-
}));
262+
->with($this->callback(fn($event) => $event instanceof RequestExecutedEvent
263+
&& $event->method === 'POST'
264+
&& $event->uri === '/api'
265+
&& $event->message !== null));
270266

271267
$thrownFactory = $this->createMock(ThrownFactory::class);
272268
$thrownFactory->expects($this->once())
@@ -277,7 +273,7 @@ public function testShouldDispatchEventOnFailure(): void
277273
try {
278274
$repository = new HttpRepositoryTestMock($clientFactory, $dispatcher, $thrownFactory);
279275
$repository->exposeRequest('POST', '/api');
280-
} catch (RepositoryException $exception) {
276+
} catch (RepositoryException) {
281277
// Expected exception
282278
}
283279
}

0 commit comments

Comments
 (0)