Hi there,
after spending quite some time trying to get my selenium tests running on circleCI I am stuck at a point where I do not know any further:
I have some environment variables which store the credentials for the database. The PHPUnit tests have these _ENV variables and succeed.
When starting the selenium tests and opening a page on localhost on selenium, my PHP framework displays an error message that it could not connect to the Database. The reason for this is that the _ENV database credentials seem not to be available for PHP “inside” Apache.
Is there a way that Apache Webserver uses these environment variables as well? See my config.yml below.
Best regards
Philipp
# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/php:7.2-apache-browsers
environment:
DB_STRING: mysql:host=127.0.0.1;dbname=eoo_test
DB_USER: root
DB_PASSWORD: test
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
- image: circleci/mysql:5.7.24
environment:
MYSQL_ROOT_PASSWORD: test
MYSQL_DATABASE: eoo_test
working_directory: ~/repo
steps:
- checkout
#install php extensions needed
- run: sudo apt install -y libpng-dev
- run: sudo docker-php-ext-install gd
- run: sudo apt install -y mysql-client
- run: sudo docker-php-ext-install pdo_mysql
- run: sudo docker-php-ext-enable pdo_mysql
#config apache
- run: sudo chmod 777 /etc/apache2/sites-enabled
- run: sudo cp /home/circleci/repo/.circleci/example.conf /etc/apache2/sites-available/eoo.conf
- run: sudo a2ensite eoo
- run: sudo service apache2 restart
#selenium
- run: mkdir test-reports
- run:
name: Download Selenium
command: curl -O http://selenium-release.storage.googleapis.com/3.5/selenium-server-standalone-3.5.3.jar
- run:
name: Start Selenium
command: java -jar selenium-server-standalone-3.5.3.jar -log stdout
Xvfb: 7055
background: true
#install composer dependecies
- run: composer install -n --prefer-dist
# run tests!
- run:
name: Run Unit tests
command: vendor/bin/phpunit