I am trying to run unit/integration tests via pipeline and using PHP unit. The DB server is Microsoft SQL.
Here's an excerpt of bitbucket-pipelines.yml
image: php:7.1.29
pipelines:
branches:
unittest:
- step:
name: New Unit Tests
caches:
- composer
script:
- mv "env/.env-unit" ".env"
# - php artisan migrate --seed
- mv -f "public/azure.web.config" "public/web.config"
- apt-get update && apt-get install -y unzip zip
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer install
- php artisan migrate --seed
# might need to wait for sqlserver to start properly here
# - sqlcmd -S localhost,1433 -U SA -P 'ThePassword' -i myhsm.sql
- vendor/bin/phpunit --bootstrap vendor/autoload.php
- zip -r unit_deployment.zip .
services:
- sqlserver
artifacts:
- unit_deployment.zip
definitions:
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2017-latest
variables:
ACCEPT_EULA: Y
SA_PASSWORD: ThePassword
It will either error out if I tried the php artisan migrate or sqlcmd is not available in this image to import the DB data. Otherwise, in the sqlserver tab things look okay. I think it comes down to getting this script to be able to import the data. Otherwise there'll be lots of
1) Tests\Unit\OrganisationControllerTest::testExample Doctrine\DBAL\Driver\PDOException: could not find driver
errors. Any suggestions on how to get MSSQL connected so my unit/integration tests can proceed?
It looks like that the build image you use - php:7.1.29 - does not have the PDO Driver for MSSQL configured / enabled.
The official PHP docker images have pre-made routines to enable PHP extensions. You can first start with a shell script executing this in context of the pipeline and then port it into a Dockerfile for your own build container that ships with the expected configuration.
Please see https://hub.docker.com/_/php the section How to install more PHP extensions which has this information.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.