services:
  app-test:
    build:
      context: .
      dockerfile: Dockerfile.test
    environment:
      - APP_ENV=testing
      - DB_CONNECTION=mysql
      - DB_HOST=mysql-test
      - DB_PORT=3306
      - DB_DATABASE=test_db
      - DB_USERNAME=root
      - DB_PASSWORD=root
      - DB_HOST_SECOND=mysql-test
      - DB_PORT_SECOND=3306
      - DB_DATABASE_SECOND=test_db
      - DB_USERNAME_SECOND=root
      - DB_PASSWORD_SECOND=root
    volumes:
      - .:/var/www/html
    depends_on:
      mysql-test:
        condition: service_healthy
    working_dir: /var/www/html

  mysql-test:
    image: mysql:8.0
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: test_db
      MYSQL_USER: test_user
      MYSQL_PASSWORD: test_pass
    ports:
      - "3307:3306"
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      timeout: 20s
      retries: 10
