createMock(TimesheetRepository::class); $repository->expects($this->once())->method('setExported')->willReturnCallback(function (array $items): void { self::assertCount(2, $items); }); $sut = new TimesheetInvoiceItemRepository($repository); $sut->setExported([new Timesheet(), null, new \stdClass(), new Timesheet(), new Activity()]); // test else for empty array /* @phpstan-ignore argument.type */ $sut->setExported([new Customer('foo'), new Project()]); } }