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 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; } }