moduleDirectory = $moduleDirectory; $this->fileIo = $fileIo; $this->arrayManager = $arrayManager; } /** * Loads mock response xml for a given request * * @param array $request * @return string * @throws NotFoundException */ public function loadForRequest(array $request): string { $moduleDir = $this->moduleDirectory->getDir('Magento_TestModuleFedex'); $type = strtolower($this->arrayManager->get(static::PATH_SERVICE_TYPE, $request) ?? 'general'); $country = strtolower($this->arrayManager->get(static::PATH_COUNTRY, $request) ?? ''); $responsePath = sprintf(static::RESPONSE_FILE_PATTERN, $moduleDir, $type, $country); if (!$this->fileIo->fileExists($responsePath)) { throw new NotFoundException( __('"%1" is not a valid mock response type for country "%2".', $type, $country) ); } return $this->fileIo->read($responsePath); } }