2019-01-26 11:42:01 +03:00
|
|
|
<?php
|
2019-10-05 18:26:10 +03:00
|
|
|
|
2019-01-26 11:42:01 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-08-11 17:30:46 +03:00
|
|
|
namespace Shlinkio\Shlink;
|
2019-01-26 11:42:01 +03:00
|
|
|
|
2019-01-26 12:19:20 +03:00
|
|
|
use GuzzleHttp\Client;
|
2020-01-01 23:11:53 +03:00
|
|
|
use Laminas\ConfigAggregator\ConfigAggregator;
|
|
|
|
use Laminas\ServiceManager\Factory\InvokableFactory;
|
2019-03-05 22:36:35 +03:00
|
|
|
use PDO;
|
2019-02-27 00:56:43 +03:00
|
|
|
|
2019-03-05 22:36:35 +03:00
|
|
|
use function Shlinkio\Shlink\Common\env;
|
2019-01-29 15:05:26 +03:00
|
|
|
use function sprintf;
|
2019-01-26 11:42:01 +03:00
|
|
|
use function sys_get_temp_dir;
|
|
|
|
|
2019-01-29 15:05:26 +03:00
|
|
|
$swooleTestingHost = '127.0.0.1';
|
|
|
|
$swooleTestingPort = 9999;
|
|
|
|
|
2019-10-06 12:21:41 +03:00
|
|
|
$buildDbConnection = function (): array {
|
2019-03-05 22:36:35 +03:00
|
|
|
$driver = env('DB_DRIVER', 'sqlite');
|
2019-03-05 22:58:48 +03:00
|
|
|
$isCi = env('TRAVIS', false);
|
2019-12-30 01:16:55 +03:00
|
|
|
$getMysqlHost = fn (string $driver) => sprintf('shlink_db%s', $driver === 'mysql' ? '' : '_maria');
|
2019-03-05 22:36:35 +03:00
|
|
|
|
2019-10-06 12:21:41 +03:00
|
|
|
$driverConfigMap = [
|
|
|
|
'sqlite' => [
|
|
|
|
'driver' => 'pdo_sqlite',
|
|
|
|
'path' => sys_get_temp_dir() . '/shlink-tests.db',
|
|
|
|
],
|
|
|
|
'mysql' => [
|
|
|
|
'driver' => 'pdo_mysql',
|
|
|
|
'host' => $isCi ? '127.0.0.1' : $getMysqlHost($driver),
|
|
|
|
'user' => 'root',
|
|
|
|
'password' => $isCi ? '' : 'root',
|
|
|
|
'dbname' => 'shlink_test',
|
|
|
|
'charset' => 'utf8',
|
|
|
|
'driverOptions' => [
|
|
|
|
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'postgres' => [
|
|
|
|
'driver' => 'pdo_pgsql',
|
|
|
|
'host' => $isCi ? '127.0.0.1' : 'shlink_db_postgres',
|
|
|
|
'user' => 'postgres',
|
|
|
|
'password' => $isCi ? '' : 'root',
|
|
|
|
'dbname' => 'shlink_test',
|
|
|
|
'charset' => 'utf8',
|
|
|
|
],
|
2020-02-03 23:20:40 +03:00
|
|
|
'mssql' => [
|
|
|
|
'driver' => 'pdo_sqlsrv',
|
|
|
|
'host' => $isCi ? '127.0.0.1' : 'shlink_db_ms',
|
|
|
|
'user' => 'sa',
|
|
|
|
'password' => $isCi ? '' : 'Passw0rd!',
|
|
|
|
'dbname' => 'shlink_test',
|
|
|
|
],
|
2019-10-06 12:21:41 +03:00
|
|
|
];
|
|
|
|
$driverConfigMap['maria'] = $driverConfigMap['mysql'];
|
|
|
|
|
|
|
|
return $driverConfigMap[$driver] ?? [];
|
2019-03-05 22:36:35 +03:00
|
|
|
};
|
|
|
|
|
2019-01-26 11:42:01 +03:00
|
|
|
return [
|
|
|
|
|
2019-01-26 12:59:24 +03:00
|
|
|
'debug' => true,
|
|
|
|
ConfigAggregator::ENABLE_CACHE => false,
|
|
|
|
|
2019-01-27 14:35:00 +03:00
|
|
|
'url_shortener' => [
|
|
|
|
'domain' => [
|
|
|
|
'schema' => 'http',
|
|
|
|
'hostname' => 'doma.in',
|
|
|
|
],
|
2019-12-31 18:29:32 +03:00
|
|
|
'validate_url' => true,
|
2019-01-27 14:35:00 +03:00
|
|
|
],
|
|
|
|
|
2020-01-01 23:11:53 +03:00
|
|
|
'mezzio-swoole' => [
|
2019-11-01 12:10:43 +03:00
|
|
|
'enable_coroutine' => false,
|
2019-01-26 11:42:01 +03:00
|
|
|
'swoole-http-server' => [
|
2019-01-29 15:05:26 +03:00
|
|
|
'host' => $swooleTestingHost,
|
|
|
|
'port' => $swooleTestingPort,
|
2019-01-26 12:19:20 +03:00
|
|
|
'process-name' => 'shlink_test',
|
2019-01-27 12:15:48 +03:00
|
|
|
'options' => [
|
|
|
|
'pid_file' => sys_get_temp_dir() . '/shlink-test-swoole.pid',
|
2019-11-01 12:10:43 +03:00
|
|
|
'enable_coroutine' => false,
|
2019-01-27 12:15:48 +03:00
|
|
|
],
|
2019-01-26 11:42:01 +03:00
|
|
|
],
|
|
|
|
],
|
|
|
|
|
2020-04-12 19:39:28 +03:00
|
|
|
'mercure' => [
|
|
|
|
'public_hub_url' => null,
|
|
|
|
'internal_hub_url' => null,
|
|
|
|
'jwt_secret' => null,
|
|
|
|
],
|
|
|
|
|
2019-01-26 11:42:01 +03:00
|
|
|
'dependencies' => [
|
2019-01-29 15:05:26 +03:00
|
|
|
'services' => [
|
|
|
|
'shlink_test_api_client' => new Client([
|
|
|
|
'base_uri' => sprintf('http://%s:%s/', $swooleTestingHost, $swooleTestingPort),
|
2019-01-30 20:28:07 +03:00
|
|
|
'http_errors' => false,
|
2019-01-29 15:05:26 +03:00
|
|
|
]),
|
|
|
|
],
|
2019-01-26 11:42:01 +03:00
|
|
|
'factories' => [
|
2019-08-11 17:30:46 +03:00
|
|
|
TestUtils\Helper\TestHelper::class => InvokableFactory::class,
|
2019-01-26 11:42:01 +03:00
|
|
|
],
|
|
|
|
],
|
|
|
|
|
|
|
|
'entity_manager' => [
|
2019-03-05 22:36:35 +03:00
|
|
|
'connection' => $buildDbConnection(),
|
2019-01-26 11:42:01 +03:00
|
|
|
],
|
|
|
|
|
2019-01-27 14:14:18 +03:00
|
|
|
'data_fixtures' => [
|
|
|
|
'paths' => [
|
|
|
|
__DIR__ . '/../../module/Rest/test-api/Fixtures',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
|
2019-01-26 11:42:01 +03:00
|
|
|
];
|