I am trying to run php unit tests on a docker container from vs code using the better phpunit extension, but I cannot get it to work.
what I have so far:-
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:
settings.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);
}
}
with this setup I get error:-
OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec format error": unknown The terminal process "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'" terminated with exit code: 126.
Where am I going wrong?