jeudi 25 avril 2019

Running phpunit acceptance test using laravel in docker leads to 404

Running acceptance tests against a route in laravel inside a docker container leads to 404 exception. How do I need to configure the APP_URL to get it running.

I tried using different APP_URLs. localhost, name of the container, 127.0.0.1,

also using the localport 8080.

The tests are running on the same machine as the webserver.

docker-compose:

version: '3.2'

services:

  webapp:
    build: .
    volumes:
    - ./:/var/www/html:delegated
    ports:
    - 80:8080
    depends_on:
    - mysql
    - redis

  mysql:
    image: mysql:5.7.23
    environment:
      MYSQL_DATABASE:
      MYSQL_USER: 
      MYSQL_PASSWORD: 
      MYSQL_ROOT_PASSWORD:
    volumes:
    - ./data/mysql/:/var/lib/mysql
    ports:
    - 3306:3306

  redis:
    image: redis:4.0.11-alpine
    volumes:
    - ./data/redis:/data

Example for calling the route:

$this->visit('/auth/register')
            ->type('testtest@test', 'email')
            ->press('Registrieren')
            ->seeInDatabase('users', ['email' => 'testtest@test.de']);

Aucun commentaire:

Enregistrer un commentaire