moduleDirectory = $moduleDirectory; $this->fileIo = $fileIo; } /** * Loads mock response xml for a given request * * @param Request $request * @return string * @throws NotFoundException */ public function loadForRequest(Request $request): string { $moduleDir = $this->moduleDirectory->getDir('Magento_TestModuleUsps'); $destination = 'us'; if (strpos($request->getUrl(), 'IntlRateV2Request') !== false) { $destination = 'ca'; } $responsePath = sprintf(static::RESPONSE_FILE_PATTERN, $moduleDir, $destination); if (!$this->fileIo->fileExists($responsePath)) { throw new NotFoundException(__('%1 is not a valid destination country.', $destination)); } return $this->fileIo->read($responsePath); } }