receive Failed asserting that actual size 1 matches expected size 2
Sender:
private int $limitContactsForRequest = 50;
public function getLimitContactsForRequest(): int
{
return $this->limitContactsForRequest;
}
public function getLeadContacts(array $contactIds = [] ): array
{
return collect($contactIds)->chunk($this->getLimitContactsForRequest())
->each(fn($contacts) => Http::post('/contacts', $contacts));
}
Http::fake();
// Mock the Sender class and its method
$mockSender = \Mockery::mock(Sender::class)->makePartial();
$mockSender->shouldReceive('getLimitContactsForRequest')->andReturn(1);
// Bind the mocked instance to the Laravel container
$this->app->instance(Sender::class, $mockSender);
// Now, when you resolve the Sender class from the container, you'll get the mock
$sender = app(Sender::class);
$sender->getLeadContacts(['1', '2']);
Http::assertSentCount(2);