This repository includes examples of how you can improve your test suite with Docker. Examples are in PHP or Node, and require you to have Docker installed locally.
Use the short instructions below, or check out the blog post (coming soon) for more details.
/ex-1
directorydocker run --rm -v $(pwd):/app -w /app composer install
docker run --rm -v $(pwd):/app -w /app php:7.2 vendor/bin/phpunit index.php
(should pass)docker run --rm -v $(pwd):/app -w /app php:7.1 vendor/bin/phpunit index.php
(should pass)docker run --rm -v $(pwd):/app -w /app php:7.0 vendor/bin/phpunit index.php
(should pass)docker run --rm -v $(pwd):/app -w /app php:5.6 vendor/bin/phpunit index.php
(should throw syntax error)/ex-2
directorydocker run --rm -v $(pwd):/app -w /app composer install
docker run --name database --rm -d -e MYSQL_ALLOW_EMPTY_PASSWORD=true mysql:5.7
docker run --rm -v $(pwd):/app -w /app --link database php:7.2 vendor/bin/phpunit index.php
(should fail)docker build . -t php-72-mysqli
docker run --rm -v $(pwd):/app -w /app --link database php-72-mysqli vendor/bin/phpunit index.php
(should pass)docker rm -f database
/ex-3
directorydocker run --rm -v $(pwd):/app -w /app composer install
docker build . -t php-72-mysqli
docker run --name database --rm -d -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_DATABASE=test mysql:5.6
. Wait a few seconds for the container to boot.docker run --rm -v $(pwd):/app -w /app --link database php-72-mysqli vendor/bin/phpunit index.php
(should fail)docker rm -f database
docker run --name database --rm -d -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_DATABASE=test mysql:5.7
. Wait a few seconds for the container to boot.docker run --rm -v $(pwd):/app -w /app --link database php-72-mysqli vendor/bin/phpunit index.php
(should pass)docker rm -f database
/ex-4
directorydocker run --rm -v $(pwd):/app -w /app composer install
docker build . -t php-72-mysqli
docker run --name database --rm -d -e MYSQL_ALLOW_EMPTY_PASSWORD=true -v $(pwd)/data:/var/lib/mysql mysql:5.7
. Wait a few seconds for the container to boot.docker run --rm -v $(pwd):/app -w /app --link database php-72-mysqli vendor/bin/phpunit index.php
(should pass)docker rm -f database
/ex-5
directorydocker-compose run --rm nightwatch
.docker-compose down
.This example adapted from blueimp's open source nightwatch repo.
/ex-6
directorydocker-compose run --rm nightwatch
.docker-compose down
.This example adapted from b00giZm's open source Node/Express example.
Copyright 2018, Karl Hughes
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.