Path: blob/master/src/infrastructure/storage/__tests__/AphrontMySQLDatabaseConnectionTestCase.php
12241 views
<?php12final class AphrontMySQLDatabaseConnectionTestCase3extends PhabricatorTestCase {45protected function getPhabricatorTestCaseConfiguration() {6return array(7// We disable this here because we're testing live MySQL connections.8self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK => false,9);10}1112public function testConnectionFailures() {13$conn = id(new HarbormasterScratchTable())->establishConnection('r');1415queryfx($conn, 'SELECT 1');1617// We expect the connection to recover from a 2006 (lost connection) when18// outside of a transaction...19$conn->simulateErrorOnNextQuery(2006);20queryfx($conn, 'SELECT 1');2122// ...but when transactional, we expect the query to throw when the23// connection is lost, because it indicates the transaction was aborted.24$conn->openTransaction();25$conn->simulateErrorOnNextQuery(2006);2627$caught = null;28try {29queryfx($conn, 'SELECT 1');30} catch (AphrontConnectionLostQueryException $ex) {31$caught = $ex;32}33$this->assertTrue($caught instanceof Exception);34}3536}373839