Skip to content

Commit

Permalink
Merge pull request #29 from devimust/fix-unit-tests
Browse files Browse the repository at this point in the history
Fix unit tests with docker
  • Loading branch information
devimust authored Dec 7, 2016
2 parents 9042bba + 5bd168a commit 1e2ccb6
Show file tree
Hide file tree
Showing 18 changed files with 120 additions and 2,131 deletions.
24 changes: 24 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
APP_ENV=local
APP_DEBUG=true
APP_KEY=ZyGTV6G2ajODKPxqxhUJDd31aBp1JmqY

ADMIN_ENABLED=true
ALLOW_UNSORTED_CATEGORY=true

DB_DEFAULT=sqlite
DB_DATABASE=test_db

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
LOCALE=en
LOCALE_FALLBACK=en

ENABLE_REGISTER=true
ENABLE_REGISTER_MAIL=false

ENABLE_ADMIN_MAIL=false

MAIL_HOST=PLEASESETME
MAIL_USERNAME=PLEASESETME
MAIL_PASSWORD=PLEASESETME
44 changes: 24 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
language: php
sudo: required

php:
- '5.6'
services:
- docker

language: ruby

env:
- NODE_RELEASE=4.x
- DOCKER_COMPOSE_VERSION: 1.8.1

before_install:
- sudo rm -rf ~/.nvm
- curl -sL "https://deb.nodesource.com/setup_${NODE_RELEASE}" | sudo -E bash -
- sudo apt-get install -y nodejs
- sudo apt-get install -y libnotify-bin # fix missing dependency required by gulp-notify
- sudo npm install -g gulp
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin

install:
- npm install
- gulp --production
- cp .env.travis .env
- mysql -e 'create database homestead_test;'
- composer self-update
- composer install --no-interaction
- php artisan key:generate
- php artisan migrate --seed
- php artisan db:seed --class=DummyBookmarksSeeder
# - php -S localhost:8000 -t public/
- cp .env.docker .env
- cp docker-compose.sample.yml docker-compose.yml
- docker-compose stop
- docker-compose rm -f
- docker-compose build

script:
- vendor/bin/phpunit
- docker-compose run --rm composer install
- docker-compose run --rm npm install
- docker-compose run --rm gulp --production
- docker-compose run --rm artisan key:generate
- docker-compose run --rm phpunit
- docker-compose up -d
- sleep 10s
- docker-compose run --rm artisan migrate:refresh --seed
- docker-compose run --rm artisan db:seed --class=DummyBookmarksSeeder
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ I welcome any feedback and contributions.
# update .env with APP_ENV=local and APP_DEBUG=false
$ composer install
$ npm install
$ gulp && gulp watch
$ gulp
$ vendor/bin/phpunit
$ gulp watch
```

#### Local docker LAMP stack
Expand All @@ -89,6 +91,7 @@ docker-compose run --rm composer install
docker-compose run --rm npm install
docker-compose run --rm gulp --production
docker-compose run --rm artisan key:generate
docker-compose run --rm phpunit
docker-compose run --rm artisan migrate:refresh --seed
docker-compose run --rm artisan db:seed --class=DummyBookmarksSeeder
```
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/PagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public function register(Request $request)

$userData = $request->all();
$userData['password'] = Hash::make($userData['password']);
$userData['administrator'] = false;

$user = User::create($userData);

Expand Down
Empty file added database/database.sqlite
Empty file.
20 changes: 13 additions & 7 deletions docker-compose.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ services:
- MYSQL_USER=testuser
- MYSQL_PASSWORD=testpassword
- MYSQL_ROOT_PASSWORD=rootp4ssword
ports:
- "3306:3306"
app:
image: debian:jessie
volumes:
- .:/app
web:
build: ./docker/web
image: rolckers/web-apache-php
ports:
- "8000:80"
depends_on:
Expand All @@ -24,14 +22,14 @@ services:
volumes_from:
- app
composer:
build: ./docker/web
image: rolckers/web-apache-php
entrypoint:
- composer
command: --help
volumes_from:
- app
artisan:
build: ./docker/web
image: rolckers/web-apache-php
entrypoint:
- php
- artisan
Expand All @@ -40,15 +38,23 @@ services:
- db
volumes_from:
- app
phpunit:
image: rolckers/web-apache-php
entrypoint:
- vendor/bin/phpunit
links:
- db
volumes_from:
- app
npm:
build: ./docker/node
image: rolckers/web-nodejs
command: --help
entrypoint:
- npm
volumes_from:
- app
gulp:
build: ./docker/node
image: rolckers/web-nodejs
command: --help
entrypoint:
- gulp
Expand Down
2 changes: 2 additions & 0 deletions docker/create-rc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ fi

docker-compose run --rm gulp --production

docker-compose run --rm phpunit

find ./storage -type 'f' | grep -v ".gitignore" | xargs rm -f

TIMESTAMP=$(date +%s)
Expand Down
7 changes: 7 additions & 0 deletions docker/kill-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

echo "Killing everything docker..."

docker kill $(docker ps -q)
docker rm -f $(docker ps -a -q)
docker rmi -f $(docker images -q)
22 changes: 0 additions & 22 deletions docker/node/Dockerfile

This file was deleted.

13 changes: 6 additions & 7 deletions docker/prep.sh → docker/prep-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ if ! [ -x "$(command -v docker-compose)" ]; then
fi

if [ ! -f ./.env ]; then
echo ".env file does not exist, copy and modify from .env.docker"
exit 1
cp ./.env.docker ./.env
echo "creating .env from .env.docker, remember to modify"
fi

if [ ! -f ./docker-compose.yml ]; then
echo "docker-compose.yml file does not exist, copy and modify from docker-compose.sample.yml"
exit 1
cp ./docker-compose.sample.yml ./docker-compose.yml
echo "creating docker-compose.yml from docker-compose.sample.yml, remember to modify"
fi

exit 0

chmod -R a+w ./storage
#chmod -R a+w ./storage

docker-compose stop
docker-compose rm -f
Expand All @@ -34,6 +32,7 @@ docker-compose run --rm composer install
docker-compose run --rm npm install
docker-compose run --rm gulp --production
docker-compose run --rm artisan key:generate
docker-compose run --rm phpunit
docker-compose up -d
sleep 10s
docker-compose run --rm artisan migrate:refresh --seed
Expand Down
48 changes: 0 additions & 48 deletions docker/web/Dockerfile

This file was deleted.

23 changes: 0 additions & 23 deletions docker/web/apache_default.conf

This file was deleted.

Loading

0 comments on commit 1e2ccb6

Please sign in to comment.