我正在尝试使用更好的 phpunit 扩展从 vs code 在 docker 容器上运行 php 单元测试,但我无法让它工作。
到目前为止我所拥有的:-
docker-compose.yml:-
version: '3.1'
services:
php:
build:
context: .
dockerfile: .docker/Dockerfile
image: laraboard
ports:
- 8000:80
restart: always
volumes:
- .:/var/www/html
networks:
- laraboard
mysql:
image: mysql:8.0
volumes:
- db_data:/var/lib/mysql
restart: always
ports:
- 3306:3306
environment:
MYSQL_DATABASE: laraboard
MYSQL_USER: root
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
networks:
- laraboard
phpmyadmin:
depends_on:
- mysql
image: phpmyadmin/phpmyadmin
restart: always
ports:
- 8001:80
environment:
PMA_HOST: mysql
MYSQL_ROOT_PASSWORD: password
networks:
- laraboard
networks:
laraboard:
volumes:
db_data:
设置.json:-
"better-phpunit.docker.enable": true,
"better-phpunit.docker.command": "docker exec laraboard_php_1",
"better-phpunit.docker.paths": {
"c:/Users/Chris/Web/laraboard": "/var/www/html"
}
ThreadTest.php:-
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ThreadsTest extends TestCase
{
/** @test */
public function a_user_can_browse_threads()
{
$response = $this->get('/threads');
$response->assertStatus(200);
}
}
通过此设置,我收到错误:-
OCI 运行时执行失败:执行失败:container_linux.go:346: 启动容器进程导致“执行格式错误”:未知终端进程“C:\Windows\System32\cmd.exe /d /c docker exec laraboard_php_1 /var/www /html/vendor/bin/phpunit.bat /var/www/html/tests/Feature/ThreadsTest.php --filter '^.*::a_user_can_browse_threads'" 终止,退出代码:126。
我哪里错了?
子衿沉夜