/** * Get item key for step item. * * @param int $type * @param string $testName * @param string $stepName * * @return bool|string */ protected function getStepKey($type, $testName, $stepName) { switch ($type) { case HTTPSTEP_ITEM_TYPE_IN: return 'web.test.in[' . quoteItemKeyParam($testName) . ',' . quoteItemKeyParam($stepName) . ',bps]'; case HTTPSTEP_ITEM_TYPE_TIME: return 'web.test.time[' . quoteItemKeyParam($testName) . ',' . quoteItemKeyParam($stepName) . ',resp]'; case HTTPSTEP_ITEM_TYPE_RSPCODE: return 'web.test.rspcode[' . quoteItemKeyParam($testName) . ',' . quoteItemKeyParam($stepName) . ']'; } return false; }
/** * Resolves macros in the item key parameters. * * @param string $key_chain an item key chain * @param string $params_raw * @param array $macros the list of macros (['{<MACRO>}' => '<value>', ...]) * @param array $types the types of macros (see getMacroPositions() for more details) * * @return string */ private function resolveItemKeyParamsMacros($key_chain, array $params_raw, array $macros, array $types) { foreach (array_reverse($params_raw) as $param_raw) { $param = $param_raw['raw']; $forced = false; switch ($param_raw['type']) { case CItemKey::PARAM_ARRAY: $param = $this->resolveItemKeyParamsMacros($param, $param_raw['parameters'], $macros, $types); break; case CItemKey::PARAM_QUOTED: $param = CItemKey::unquoteParam($param); $forced = true; // break; is not missing here // break; is not missing here case CItemKey::PARAM_UNQUOTED: $matched_macros = $this->getMacroPositions($param, $types); foreach (array_reverse($matched_macros, true) as $pos => $macro) { $param = substr_replace($param, $macros[$macro], $pos, strlen($macro)); } $param = quoteItemKeyParam($param, $forced); break; } $key_chain = substr_replace($key_chain, $param, $param_raw['pos'], strlen($param_raw['raw'])); } return $key_chain; }