shouldReceive('Query')->andReturnUsing(function($val) use ($count, $data) { if(stristr($val, 'count')) { return $count; } return Arr::take($data,4); }); app()->singleton(QuickbooksInterface::class, fn() => new QuickbooksSDK($sdkMock)); $this->service = app(QuickbooksService::class); } public function testImportCustomers() { $collection = $this->service->fetchCustomers(4); $this->assertInstanceOf(Collection::class, $collection); $this->assertEquals(4, $collection->count()); $this->assertNotNull($item = $collection->whereStrict('CompanyName', "Cool Cars")->first()); $this->assertEquals("Grace", $item['GivenName']); } }