Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Laravel with PHP unit trying to connect to Microsoft SQL server

mark.arnum
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 17, 2019

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?

 

1 answer

1 accepted

0 votes
Answer accepted
ktomk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2019

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events