问题与Guzzle Symfony GET请求使用Symfony3.4中的接受环境进行behat测试

问题描述 投票:0回答:1

我有这样的nginx配置:

server {
    server_name symfony.dew;
    root /var/www/symfony/web;
    location / {
    try_files $uri @rewriteapp;
    }
    location @rewriteapp {
    rewrite ^(.*)$ /app.php/$1 last;
    }
    location ~ ^/(app|app_dev|app_acceptance|app_test|config)\.php(/|$) {
    fastcgi_pass php-upstream;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME
    $document_root$fastcgi_script_name;
    fastcgi_param HTTPS off;
    }
    error_log /var/log/nginx/symfony_error.log;
    access_log /var/log/nginx/symfony_access.log;

} 

当我使用Postman url测试我的api:localhost:8080 / app_acceptance / api / v1 / something / 1它运行良好,它使用xxx_acceptance数据库查找数据,但是当我在guzzle中执行请求时:

$this->client = new Client(['base_uri' => 'http://nginx/app_acceptance.php', 'timeout' => 2.0]);

它以某种方式重定向到app.php,查询转到xxx数据库而不是xxx_acceptance。我在我的docker-compose“nginx”中所以我正在使用它,当我为guzzle建立链接时。我正在使用最新版本的Docker,Behat和Guzzle。

symfony testing guzzle behat acceptance
1个回答
0
投票

我认为基本网址错过了端口:

$this->client = new Client([
    'base_uri' => 'http://nginx:8080/app_acceptance.php',
    'timeout' => 2.0,
]);
© www.soinside.com 2019 - 2024. All rights reserved.