3 final class AphrontMySQLDatabaseConnectionTestCase
4 extends PhabricatorTestCase
{
6 protected function getPhabricatorTestCaseConfiguration() {
8 // We disable this here because we're testing live MySQL connections.
9 self
::PHABRICATOR_TESTCONFIG_ISOLATE_LISK
=> false,
13 public function testConnectionFailures() {
14 $conn = id(new HarbormasterScratchTable())->establishConnection('r');
16 queryfx($conn, 'SELECT 1');
18 // We expect the connection to recover from a 2006 (lost connection) when
19 // outside of a transaction...
20 $conn->simulateErrorOnNextQuery(2006);
21 queryfx($conn, 'SELECT 1');
23 // ...but when transactional, we expect the query to throw when the
24 // connection is lost, because it indicates the transaction was aborted.
25 $conn->openTransaction();
26 $conn->simulateErrorOnNextQuery(2006);
30 queryfx($conn, 'SELECT 1');
31 } catch (AphrontConnectionLostQueryException
$ex) {
34 $this->assertTrue($caught instanceof Exception
);