createMock(TimesheetRepository::class); $repository->expects($this->once())->method('setExported')->willReturnCallback(function (array $items) { 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-next-line */ $sut->setExported([new Customer('foo'), new Project()]); } }