$data = "{ 'your_json_answer_from_api } ";
$apiMock = $this->createMock(ApiService::class);
$apiMock = $apiMock->expects(self::once())->method('rest')->willReturn($data);
$shop->setApi($api);
// Your test/asserts
(function () use ($apiMock) {$this->api = $apiMock;})->call($shop);