public function testTransactionRollback()
 {
     $check = array();
     $phid = new HarbormasterScratchTable();
     $phid->openTransaction();
     for ($ii = 0; $ii < 3; $ii++) {
         $key = $this->generateTestData();
         $obj = new HarbormasterScratchTable();
         $obj->setData($key);
         $obj->save();
         $check[] = $key;
     }
     $phid->killTransaction();
     foreach ($check as $key) {
         $this->assertNoSuchRow($key);
     }
 }
 public function testRejectMySQLBMPQueries()
 {
     $table = new HarbormasterScratchTable();
     $conn_r = $table->establishConnection('w');
     $snowman = "☃";
     $gclef = "𝄞";
     qsprintf($conn_r, 'SELECT %B', $snowman);
     qsprintf($conn_r, 'SELECT %s', $snowman);
     qsprintf($conn_r, 'SELECT %B', $gclef);
     $caught = null;
     try {
         qsprintf($conn_r, 'SELECT %s', $gclef);
     } catch (AphrontCharacterSetQueryException $ex) {
         $caught = $ex;
     }
     $this->assertTrue($caught instanceof AphrontCharacterSetQueryException);
 }
Ejemplo n.º 3
0
 public function testReadableTransactions()
 {
     // TODO: When we have semi-durable fixtures, use those instead. This is
     // extremely hacky.
     LiskDAO::endIsolateAllLiskEffectsToTransactions();
     try {
         $data = Filesystem::readRandomCharacters(32);
         $obj = new HarbormasterScratchTable();
         $obj->openTransaction();
         $obj->setData($data);
         $obj->save();
         $loaded = id(new HarbormasterScratchTable())->loadOneWhere('data = %s', $data);
         $obj->killTransaction();
         $this->assertTrue($loaded !== null, 'Reads inside transactions should have transaction visibility.');
         LiskDAO::beginIsolateAllLiskEffectsToTransactions();
     } catch (Exception $ex) {
         LiskDAO::beginIsolateAllLiskEffectsToTransactions();
         throw $ex;
     }
 }
Ejemplo n.º 4
0
 public function testCheckProperty()
 {
     $scratch = new HarbormasterScratchTable();
     $scratch->getData();
     $this->assertException('Exception', array($this, 'getData'));
 }