Skip to content

Commit

Permalink
Catch MySQL connection error on unit tests
Browse files Browse the repository at this point in the history
Fixes: phpmyadmin/scripts#22
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed Jan 24, 2020
1 parent 3db8949 commit fb134b0
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions test/selenium/TestBase.php
Expand Up @@ -86,13 +86,18 @@ protected function setUp(): void
return;
}

$this->_mysqli = new mysqli(
$GLOBALS['TESTSUITE_SERVER'],
$GLOBALS['TESTSUITE_USER'],
$GLOBALS['TESTSUITE_PASSWORD'],
'mysql',
(int) $GLOBALS['TESTSUITE_PORT']
);
try {
$this->_mysqli = new mysqli(
$GLOBALS['TESTSUITE_SERVER'],
$GLOBALS['TESTSUITE_USER'],
$GLOBALS['TESTSUITE_PASSWORD'],
'mysql',
(int) $GLOBALS['TESTSUITE_PORT']
);
} catch (Exception $e) {
// when localhost is used, it tries to connect to a socket and throws and error
$this->markTestSkipped('Failed to connect to MySQL (' . $e->getMessage() . ')');
}

if ($this->_mysqli->connect_errno) {
$this->markTestSkipped('Failed to connect to MySQL (' . $this->_mysqli->error . ')');
Expand Down

0 comments on commit fb134b0

Please sign in to comment.