问题描述
我正在使用 Panther 来测试我的 Symfony 5 应用程序。
我需要测试我的 Stripe 支付系统。我可以填写表单字段,但是当我提交 Stripe 时出现错误:
(index):1 您可以通过 HTTP 测试您的 Stripe.js 集成。然而, 实时 Stripe.js 集成必须使用 HTTPS。
确实,Panther 似乎不是在 HTTPS 中启动客户端,而是在 HTTP 中启动。
我在本地安装了 Symfony SSL 证书(所以我可以访问 https://127.0.0.1:8000)
但是 Panther 只会运行 http://127.0.0.1:9080(9080 是 panther 在启动测试时占用的端口)
我该如何解决这个问题? 我在文档( https://github.com/symfony/panther )中没有看到任何选项,也没有在这个主题上看到任何出路
这是我的代码:
$client = static::createPantherClient();
$client->request('GET','/website/tarifs');
//fill the form and submit
解决方法
Panther 的内部网络服务器仅使用 http(如您所见 in the code)。如果您想使用 SSL,您必须使用您自己的网络服务器来处理加密层。这作为documented:
public function testMyApp(): void
{
$pantherClient = static::createPantherClient(['external_base_uri' => 'https://localhost']);
// the PHP integrated web server will not be started
}