Skip to content

Latest commit

 

History

History
87 lines (54 loc) · 2.09 KB

README.md

File metadata and controls

87 lines (54 loc) · 2.09 KB

MySQL DBAL Dev

Development environment for MySQL DBAL.

Overview

This repository contains everything you need to test MySQL DBAL. It consists of two interconnected Docker containers, one running PHP and another running either MySQL or MariaDB.

Requirements

Docker Engine 1.13 or above.

Download MySQL DBAL

Place a copy of MySQL DBAL under the repos directory. You can use any cloning strategy you may like, just make sure the clone's path is repos/mysql-dbal.

Build the custom PHP image

The following command line will use the Dockerfile under docker/php to build a custom PHP image with Composer already installed:

$ docker-compose build php

Database images are pulled from Dockerhub, so there's no need to build them yourself.

Run the database container

You can run the tests either against MySQL or MariaDB.

MySQL

The following command line will pull the MySQL image from Dockerhub, if necessary, and spin up a new container based on it:

$ docker-compose up -d db

MariaDB

The following command line will pull the MariaDB image from Dockerhub, if necessary, and spin up a new container based on it:

$ docker-compose -f docker-compose.yml -f docker-compose.mariadb.yml up -d db

Check the database status

To check if the container is running and the database configurations are correctly set up, you can use

$ docker exec -ti mysql-dbal-db mysql -u testdb -ptestdb testdb -e 'show databases;'

Run the tests from inside the PHP container

Spin up a new PHP container:

$ docker-compose run --rm php

From inside that container, install the Composer packages:

$ composer install

You can then run the tests:

$ DB_HOST=mysql-dbal-db \
DB_DATABASE=testdb \
DB_USERNAME=testdb \
DB_PASSWORD=testdb \
./vendor/bin/codecept run unit

Bring everything down

To delete all containers, run

$ docker-compose down