mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-23 21:27:44 +03:00
98 lines
2.5 KiB
PHP
98 lines
2.5 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace ShlinkioTest\Shlink;
|
|
|
|
use GuzzleHttp\Client;
|
|
use PDO;
|
|
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');
|
|
|
|
switch ($driver) {
|
|
case 'sqlite':
|
|
return [
|
|
'driver' => 'pdo_sqlite',
|
|
'path' => sys_get_temp_dir() . '/shlink-tests.db',
|
|
];
|
|
case 'mysql':
|
|
return [
|
|
'driver' => 'pdo_mysql',
|
|
'host' => 'shlink_db',
|
|
'user' => 'root',
|
|
'password' => 'root',
|
|
'dbname' => 'shlink_test',
|
|
'charset' => 'utf8',
|
|
'driverOptions' => [
|
|
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
|
|
],
|
|
];
|
|
case 'postgres':
|
|
return [
|
|
'driver' => 'pdo_pgsql',
|
|
'host' => 'shlink_db_postgres',
|
|
'user' => 'postgres',
|
|
'password' => 'root',
|
|
'dbname' => 'shlink_test',
|
|
'charset' => 'utf8',
|
|
];
|
|
default:
|
|
return [];
|
|
}
|
|
};
|
|
|
|
return [
|
|
|
|
'debug' => true,
|
|
ConfigAggregator::ENABLE_CACHE => false,
|
|
|
|
'url_shortener' => [
|
|
'domain' => [
|
|
'schema' => 'http',
|
|
'hostname' => 'doma.in',
|
|
],
|
|
],
|
|
|
|
'zend-expressive-swoole' => [
|
|
'swoole-http-server' => [
|
|
'host' => $swooleTestingHost,
|
|
'port' => $swooleTestingPort,
|
|
'process-name' => 'shlink_test',
|
|
'options' => [
|
|
'pid_file' => sys_get_temp_dir() . '/shlink-test-swoole.pid',
|
|
],
|
|
],
|
|
],
|
|
|
|
'dependencies' => [
|
|
'services' => [
|
|
'shlink_test_api_client' => new Client([
|
|
'base_uri' => sprintf('http://%s:%s/', $swooleTestingHost, $swooleTestingPort),
|
|
'http_errors' => false,
|
|
]),
|
|
],
|
|
'factories' => [
|
|
Common\TestHelper::class => InvokableFactory::class,
|
|
],
|
|
],
|
|
|
|
'entity_manager' => [
|
|
'connection' => $buildDbConnection(),
|
|
],
|
|
|
|
'data_fixtures' => [
|
|
'paths' => [
|
|
__DIR__ . '/../../module/Rest/test-api/Fixtures',
|
|
],
|
|
],
|
|
|
|
];
|