shlink/config/test/test_config.global.php

102 lines
2.6 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
2019-08-11 09:30:46 -05:00
namespace Shlinkio\Shlink;
2019-01-26 03:19:20 -06:00
use GuzzleHttp\Client;
use PDO;
2019-01-26 03:59:24 -06:00
use Zend\ConfigAggregator\ConfigAggregator;
use Zend\ServiceManager\Factory\InvokableFactory;
use function Shlinkio\Shlink\Common\env;
use function sprintf;
use function sys_get_temp_dir;
$swooleTestingHost = '127.0.0.1';
$swooleTestingPort = 9999;
$buildDbConnection = function () {
$driver = env('DB_DRIVER', 'sqlite');
$isCi = env('TRAVIS', false);
switch ($driver) {
case 'sqlite':
return [
'driver' => 'pdo_sqlite',
'path' => sys_get_temp_dir() . '/shlink-tests.db',
];
case 'mysql':
return [
'driver' => 'pdo_mysql',
'host' => $isCi ? '127.0.0.1' : 'shlink_db',
'user' => 'root',
'password' => $isCi ? '' : 'root',
'dbname' => 'shlink_test',
'charset' => 'utf8',
'driverOptions' => [
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
],
];
case 'postgres':
return [
'driver' => 'pdo_pgsql',
'host' => $isCi ? '127.0.0.1' : 'shlink_db_postgres',
'user' => 'postgres',
'password' => $isCi ? '' : 'root',
'dbname' => 'shlink_test',
'charset' => 'utf8',
];
default:
return [];
}
};
return [
2019-01-26 03:59:24 -06:00
'debug' => true,
ConfigAggregator::ENABLE_CACHE => false,
2019-01-27 05:35:00 -06:00
'url_shortener' => [
'domain' => [
'schema' => 'http',
'hostname' => 'doma.in',
],
],
'zend-expressive-swoole' => [
'swoole-http-server' => [
'host' => $swooleTestingHost,
'port' => $swooleTestingPort,
2019-01-26 03:19:20 -06:00
'process-name' => 'shlink_test',
'options' => [
'pid_file' => sys_get_temp_dir() . '/shlink-test-swoole.pid',
2019-07-19 13:28:28 -05:00
'worker_num' => 1,
'task_worker_num' => 1,
],
],
],
'dependencies' => [
'services' => [
'shlink_test_api_client' => new Client([
'base_uri' => sprintf('http://%s:%s/', $swooleTestingHost, $swooleTestingPort),
'http_errors' => false,
]),
],
'factories' => [
2019-08-11 09:30:46 -05:00
TestUtils\Helper\TestHelper::class => InvokableFactory::class,
],
],
'entity_manager' => [
'connection' => $buildDbConnection(),
],
2019-01-27 05:14:18 -06:00
'data_fixtures' => [
'paths' => [
__DIR__ . '/../../module/Rest/test-api/Fixtures',
],
],
];