Пример #1
0
 public static function generateNewPHID($type, array $config = array())
 {
     $owner = idx($config, 'owner');
     $parent = idx($config, 'parent');
     if (!$type) {
         throw new Exception("Can not generate PHID with no type.");
     }
     $uniq = Filesystem::readRandomCharacters(20);
     $phid = 'PHID-' . $type . '-' . $uniq;
     $phid_rec = new PhabricatorPHID();
     $phid_rec->setPHIDType($type);
     $phid_rec->setOwnerPHID($owner);
     $phid_rec->setParentPHID($parent);
     $phid_rec->setPHID($phid);
     $phid_rec->save();
     return $phid;
 }
 public function testTransactionRollback()
 {
     $check = array();
     $phid = new PhabricatorPHID();
     $phid->openTransaction();
     for ($ii = 0; $ii < 3; $ii++) {
         $test_phid = $this->generateTestPHID();
         $obj = new PhabricatorPHID();
         $obj->setPHID($test_phid);
         $obj->setPHIDType('TEST');
         $obj->setOwnerPHID('PHID-UNIT-!!!!');
         $obj->save();
         $check[] = $test_phid;
     }
     $phid->killTransaction();
     foreach ($check as $test_phid) {
         $this->assertNoSuchPHID($test_phid);
     }
 }