Skip to content

Instantly share code, notes, and snippets.

@gordonbanderson
Created April 25, 2018 02:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gordonbanderson/d8a9bffe6a0fef8f9b71927bdc34660d to your computer and use it in GitHub Desktop.
Save gordonbanderson/d8a9bffe6a0fef8f9b71927bdc34660d to your computer and use it in GitHub Desktop.
Running SilverStripe Tests Locally For a Module Using Docker
# Generated by SilverStripe Installer
SS_BASE_URL="http://localhost"
SS_DATABASE_CLASS="MySQLPDODatabase"
SS_DATABASE_NAME="unittesting"
SS_DATABASE_PASSWORD=""
SS_DATABASE_SERVER="database"
SS_DATABASE_USERNAME="root"
SS_ENVIRONMENT_TYPE="dev"
version: '2'
services:
web:
# build:
# context: ./docker-ss
image: brettt89/silverstripe-web:7.1-platform
working_dir: /var/www
volumes:
- .:/var/www/html
ports:
- "80:80"
database:
image: mariadb
volumes:
- ~/srv/docker/data/mysql/suilven/testing:/var/lib/mysql
restart: always
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=true
Get a bash shell on the web container
```
sudo docker-compose exec web /bin/bash
```
Clone your module
```
cd /var/www/html/ && git clone <your module>
```
Execute commands from either Travis or Ciricle CI, this is an example. Note the last step may take likes of 10 mins.
```
composer validate
composer require --prefer-source --no-update silverstripe/recipe-cms:1.1.x-dev
composer install --prefer-source --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
```
Run your tests!
```
phpdbg -qrr vendor/bin/phpunit -d memory_limit=512M --coverage-clover=coverage.xml tests/
```
Optionally upload coverage
```
bash <(curl -s https://codecov.io/bash) -f coverage.xml
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment