22/**
33 * @copyright 2016-2017 Hostnet B.V.
44 */
5+ declare (strict_types = 1 );
56namespace Hostnet \Component \DatabaseTest ;
67
78/**
@@ -26,6 +27,8 @@ class MysqlPersistentConnection implements ConnectionInterface
2627 */
2728 const CMD_PERSISTENT = __DIR__ . '/../bin/mysql_persistent.sh ' ;
2829
30+ const CMD_TRAVIS = __DIR__ . '/../bin/mysql_travis.sh ' ;
31+
2932 /**
3033 * @var array
3134 */
@@ -34,30 +37,31 @@ class MysqlPersistentConnection implements ConnectionInterface
3437 /**
3538 * @var resource
3639 */
37- private $ pipe = null ;
40+ private $ pipe ;
3841
3942 /**
4043 * @var resource
4144 */
42- private $ process = null ;
45+ private $ process ;
4346
4447 /**
4548 * Start the daemon if needed and create a database.
4649 */
4750 public function __construct ()
4851 {
4952 $ descriptor_spec = [
50- 0 => [" pipe " , " r " ], // stdin is a pipe that the child will read from
51- 1 => [" pipe " , " w " ], // stdout is a pipe that the child will write to
53+ 0 => [' pipe ' , ' r ' ], // stdin is a pipe that the child will read from
54+ 1 => [' pipe ' , ' w ' ], // stdout is a pipe that the child will write to
5255 ];
5356
54- $ this ->process = proc_open (self ::CMD_PERSISTENT , $ descriptor_spec , $ pipes );
57+ $ cmd = getenv ('TRAVIS ' ) ? self ::CMD_TRAVIS : self ::CMD_PERSISTENT ;
58+ $ this ->process = proc_open ($ cmd , $ descriptor_spec , $ pipes );
5559 $ data = fread ($ pipes [1 ], 1024 );
5660
5761 fclose ($ pipes [1 ]);
5862 $ this ->pipe = $ pipes [0 ];
5963
60- foreach (explode (" , " , $ data ) as $ param ) {
64+ foreach (explode (' , ' , $ data ) as $ param ) {
6165 if (strpos ($ param , ': ' ) !== false ) {
6266 list ($ key , $ value ) = explode (': ' , $ param );
6367 $ this ->connection_params [trim ($ key )] = trim ($ value );
@@ -78,7 +82,7 @@ public function __destruct()
7882 * {@inheritdoc}
7983 * @return array
8084 */
81- public function getConnectionParams ()
85+ public function getConnectionParams (): array
8286 {
8387 return $ this ->connection_params ;
8488 }
0 commit comments