diff --git a/.travis.yml b/.travis.yml index 8b232c76..d53d2ed0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,6 @@ php: - '7.4' services: - - mysql - - postgresql - docker cache: @@ -26,8 +24,7 @@ install: - composer install --no-interaction --prefer-dist before_script: - - mysql -e 'CREATE DATABASE shlink_test;' - - psql -c 'create database shlink_test;' -U postgres + - docker-compose up shlink_db shlink_db_postgres shlink_db_maria shlink_db_ms -d - mkdir build - export DOCKERFILE_CHANGED=$(git diff ${TRAVIS_COMMIT_RANGE:-origin/master} --name-only | grep Dockerfile) diff --git a/composer.json b/composer.json index 39c1e6db..111b60c4 100644 --- a/composer.json +++ b/composer.json @@ -109,7 +109,7 @@ ], "test:ci": [ "@test:unit:ci", - "@test:db:ci", + "@test:db", "@test:api:ci" ], "test:unit": "phpdbg -qrr vendor/bin/phpunit --order-by=random --colors=always --coverage-php build/coverage-unit.cov --testdox", @@ -121,11 +121,6 @@ "@test:db:postgres", "@test:db:ms" ], - "test:db:ci": [ - "@test:db:sqlite", - "@test:db:mysql", - "@test:db:postgres" - ], "test:db:sqlite": "APP_ENV=test phpdbg -qrr vendor/bin/phpunit --order-by=random --colors=always --coverage-php build/coverage-db.cov --testdox -c phpunit-db.xml", "test:db:mysql": "DB_DRIVER=mysql composer test:db:sqlite", "test:db:maria": "DB_DRIVER=maria composer test:db:sqlite", @@ -152,8 +147,7 @@ "test:ci": "Runs all test suites, generating all needed reports and logs for CI envs", "test:unit": "Runs unit test suites", "test:unit:ci": "Runs unit test suites, generating all needed reports and logs for CI envs", - "test:db": "Runs database test suites on a SQLite, MySQL, MariaDB and PostgreSQL", - "test:db:ci": "Runs database test suites on a SQLite, MySQL and PostgreSQL", + "test:db": "Runs database test suites on a SQLite, MySQL, MariaDB, PostgreSQL and MsSQL", "test:db:sqlite": "Runs database test suites on a SQLite database", "test:db:mysql": "Runs database test suites on a MySQL database", "test:db:maria": "Runs database test suites on a MariaDB database", diff --git a/config/test/test_config.global.php b/config/test/test_config.global.php index 6aad5375..0086bcd0 100644 --- a/config/test/test_config.global.php +++ b/config/test/test_config.global.php @@ -20,6 +20,7 @@ $buildDbConnection = function (): array { $driver = env('DB_DRIVER', 'sqlite'); $isCi = env('TRAVIS', false); $getMysqlHost = fn (string $driver) => sprintf('shlink_db%s', $driver === 'mysql' ? '' : '_maria'); + $getCiMysqlPort = fn (string $driver) => $driver === 'mysql' ? '3307' : '3308'; $driverConfigMap = [ 'sqlite' => [ @@ -29,8 +30,9 @@ $buildDbConnection = function (): array { 'mysql' => [ 'driver' => 'pdo_mysql', 'host' => $isCi ? '127.0.0.1' : $getMysqlHost($driver), + 'port' => $isCi ? $getCiMysqlPort($driver) : '3306', 'user' => 'root', - 'password' => $isCi ? '' : 'root', + 'password' => 'root', 'dbname' => 'shlink_test', 'charset' => 'utf8', 'driverOptions' => [ @@ -41,8 +43,9 @@ $buildDbConnection = function (): array { 'postgres' => [ 'driver' => 'pdo_pgsql', 'host' => $isCi ? '127.0.0.1' : 'shlink_db_postgres', + 'port' => $isCi ? '5433' : '5432', 'user' => 'postgres', - 'password' => $isCi ? '' : 'root', + 'password' => 'root', 'dbname' => 'shlink_test', 'charset' => 'utf8', ], @@ -50,7 +53,7 @@ $buildDbConnection = function (): array { 'driver' => 'pdo_sqlsrv', 'host' => $isCi ? '127.0.0.1' : 'shlink_db_ms', 'user' => 'sa', - 'password' => $isCi ? '' : 'Passw0rd!', + 'password' => 'Passw0rd!', 'dbname' => 'shlink_test', ], ];