123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- declare(strict_types=1);
- namespace Shlinkio\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 (): array {
- $driver = env('DB_DRIVER', 'sqlite');
- $isCi = env('TRAVIS', false);
- $getMysqlHost = function (string $driver) {
- return sprintf('shlink_db%s', $driver === 'mysql' ? '' : '_maria');
- };
- $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',
- ],
- ];
- $driverConfigMap['maria'] = $driverConfigMap['mysql'];
- return $driverConfigMap[$driver] ?? [];
- };
- 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',
- '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' => [
- TestUtils\Helper\TestHelper::class => InvokableFactory::class,
- ],
- ],
- 'entity_manager' => [
- 'connection' => $buildDbConnection(),
- ],
- 'data_fixtures' => [
- 'paths' => [
- __DIR__ . '/../../module/Rest/test-api/Fixtures',
- ],
- ],
- ];
|