Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在FeatureContext方法中获取uuid(动态值)_Php_Testing_Bdd_Behat_Symfony 2.8 - Fatal编程技术网

Php 如何在FeatureContext方法中获取uuid(动态值)

Php 如何在FeatureContext方法中获取uuid(动态值),php,testing,bdd,behat,symfony-2.8,Php,Testing,Bdd,Behat,Symfony 2.8,我的代码只能访问硬编码ID(/api/user/{ID})。但我希望它与动态值(例如:uuid)一起工作 额外功能: private function attachQueries($url) { foreach ($this->queries as $key => $value) { if(strpos($url,'?') !== false) { $url .= '&' .$key. '=' .$value;

我的代码只能访问硬编码ID(/api/user/{ID})。但我希望它与动态值(例如:uuid)一起工作

额外功能:

 private function attachQueries($url)
{
    foreach ($this->queries as $key => $value) {
        if(strpos($url,'?') !== false) {
            $url .= '&' .$key. '=' .$value;
        } else {
            $url .= '?' .$key. '=' .$value;
        }
    }

    return $url;
}

private function isUrlContainsRuntimeParameters($url)
{
    preg_match(self::RUNTIME_PARAMETER_PATTERN, $url, $matches);

    return !empty($matches);
}

private function mergeRuntimeParametersValues($parameter)
{
    preg_match(self::RUNTIME_PARAMETER_PATTERN, $parameter, $matches);

    return empty($matches)
        ? $parameter
        : preg_replace(self::RUNTIME_PARAMETER_PATTERN, $this->runtimeParameters[$matches[1]], $parameter);
}

我想重建方法“iSendARequestTo()”,使其与动态条令值(例如uuid)一起工作。

我不确定您问的是哪个问题。您能改进它吗?在我的场景:场景:用户更新当我向“/api/User/f70113bf-dc99”发送“PUT”请求时,响应代码应该是204“f70113bf-dc99”是uuid,它是动态生成的并存储在DB中。现在,我的方法可以访问url:/api/user/10,但我希望它可以与动态uuid(如/api/user/f70113bf-dc99)一起使用。您需要在以前的方法/DB或其他地方的请求中获得此信息。
 private function attachQueries($url)
{
    foreach ($this->queries as $key => $value) {
        if(strpos($url,'?') !== false) {
            $url .= '&' .$key. '=' .$value;
        } else {
            $url .= '?' .$key. '=' .$value;
        }
    }

    return $url;
}

private function isUrlContainsRuntimeParameters($url)
{
    preg_match(self::RUNTIME_PARAMETER_PATTERN, $url, $matches);

    return !empty($matches);
}

private function mergeRuntimeParametersValues($parameter)
{
    preg_match(self::RUNTIME_PARAMETER_PATTERN, $parameter, $matches);

    return empty($matches)
        ? $parameter
        : preg_replace(self::RUNTIME_PARAMETER_PATTERN, $this->runtimeParameters[$matches[1]], $parameter);
}