I suggest to add testing capabilites, mainly Behat and PhantomJS.
Behat is "an open source Behavior-Driven Development framework for PHP" and there are plans to add it Drupal (https://www.drupal.org/node/2232271). In fact, some parts of Behat (mainly Mink) are already added to Drupal 8 (see https://www.drupal.org/node/2232861).
PhantomJS "is a headless WebKit scriptable with a JavaScript API". Used by Behat (thanks to Mink), it allows to test sites with a real browser (full JS support).
I've added PhantomJS to my own docker-compose file, it looks like this now:
#regular dev containers above...here starts test containers
testdb:
image: wodby/drupal-mariadb
environment:
MYSQL_RANDOM_ROOT_PASSWORD: 1
MYSQL_DATABASE: drupal
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
# command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci # The simple way to override the mariadb config.
volumes:
- ./docker-runtime/testdb:/var/lib/mysql
- ./docker-runtime/mariadb-init:/docker-entrypoint-initdb.d # Place init .sql file(s) here.
testphp:
image: wodby/drupal-php:7.0 # Allowed: 7.0, 5.6.
environment:
PHP_SITE_NAME: test
PHP_HOST_NAME: localhost:8001
PHP_DOCROOT: web
PRESSFLOW_SETTINGS: '{"databases":{"default":{"default":{"database":"drupal","username":"drupal","password":"drupal","host":"testdb","port":"3306","driver":"mysql","prefix":"","collation":"utf8mb4_general_ci"}}}}'
PANTHEON_ENVIRONMENT: local
DRUPAL_HASH_SALT: mmm...salty
# PHP_XDEBUG_ENABLED: 1
# PHP_XDEBUG_AUTOSTART: 1
# PHP_XDEBUG_REMOTE_CONNECT_BACK: 0 # This is needed to respect remote.host setting bellow
# PHP_XDEBUG_REMOTE_HOST: "10.254.254.254" # You will also need to 'sudo ifconfig lo0 alias 10.254.254.254'
volumes:
- ./:/var/www/html
testnginx:
image: wodby/drupal-nginx
environment:
NGINX_SERVER_NAME: localhost
NGINX_UPSTREAM_NAME: testphp
NGINX_DOCROOT: web
DRUPAL_VERSION: 8 # Allowed: 7, 8.
volumes_from:
- testphp
ports:
- "8001:80"
phantomjs:
image: cmfatih/phantomjs
volumes_from:
- testphp
links:
- testnginx
ports:
- 4444
entrypoint: phantomjs
command: "--webdriver=4444"
This lets me run Codeception acceptance tests using PhantomJS
+1 for testing capabilities!
So behat can be installed via composer. As for phantomjs – we should probably include it as a default commented service and add docs.
+1 This would be great to get in as a commented service
In case it is helpful for someone else, I ultimately added this to the default wodby/docker4drupal docker-compose.yml to get it running:
phantomjs:
image: wernight/phantomjs:2
volumes_from:
- php
links:
- nginx
entrypoint: phantomjs
command: "--ssl-protocol=any --ignore-ssl-errors=true /var/www/html/vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768"
Then something like this to run a test that depends on phantomjs:
docker-compose exec php sh
su - www-data
cd /var/www/html/web
php ./core/scripts/run-tests.sh --url http://nginx --verbose --php "/usr/local/bin/php" --class "Drupal\Tests\workflows\Functional\WorkflowUiTest"
@scotteuser Is it possible to run the phantomjs from PHP container from a specific php file using shell_exec?
I am creating the command dynamically and the necessary files that I want to throw to phantomjs, so, if there is a way to run it from the HP container would be great.
Sorry I'm not sure
Most helpful comment
I've added PhantomJS to my own docker-compose file, it looks like this now:
This lets me run Codeception acceptance tests using PhantomJS