[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/infrastructure/storage/__tests__/ -> AphrontMySQLDatabaseConnectionTestCase.php (source)

   1  <?php
   2  
   3  final class AphrontMySQLDatabaseConnectionTestCase
   4    extends PhabricatorTestCase {
   5  
   6    protected function getPhabricatorTestCaseConfiguration() {
   7      return array(
   8        // We disable this here because we're testing live MySQL connections.
   9        self::PHABRICATOR_TESTCONFIG_ISOLATE_LISK => false,
  10      );
  11    }
  12  
  13    public function testConnectionFailures() {
  14      $conn = id(new HarbormasterScratchTable())->establishConnection('r');
  15  
  16      queryfx($conn, 'SELECT 1');
  17  
  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');
  22  
  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);
  27  
  28        $caught = null;
  29        try {
  30          queryfx($conn, 'SELECT 1');
  31        } catch (AphrontConnectionLostQueryException $ex) {
  32          $caught = $ex;
  33        }
  34        $this->assertTrue($caught instanceof Exception);
  35    }
  36  
  37  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1