@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 79 lines 2.2 kB view raw
1<?php 2 3abstract class ConpherenceTestCase extends PhabricatorTestCase { 4 5 protected function addParticipants( 6 PhabricatorUser $actor, 7 ConpherenceThread $conpherence, 8 array $participant_phids) { 9 10 $xactions = array( 11 id(new ConpherenceTransaction()) 12 ->setTransactionType( 13 ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE) 14 ->setNewValue(array('+' => $participant_phids)), 15 ); 16 $editor = id(new ConpherenceEditor()) 17 ->setActor($actor) 18 ->setContentSource($this->newContentSource()) 19 ->applyTransactions($conpherence, $xactions); 20 21 } 22 23 protected function removeParticipants( 24 PhabricatorUser $actor, 25 ConpherenceThread $conpherence, 26 array $participant_phids) { 27 28 $xactions = array( 29 id(new ConpherenceTransaction()) 30 ->setTransactionType( 31 ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE) 32 ->setNewValue(array('-' => $participant_phids)), 33 ); 34 $editor = id(new ConpherenceEditor()) 35 ->setActor($actor) 36 ->setContentSource($this->newContentSource()) 37 ->applyTransactions($conpherence, $xactions); 38 } 39 40 protected function addMessageWithFile( 41 PhabricatorUser $actor, 42 ConpherenceThread $conpherence) { 43 44 $file = $this->generateTestFile($actor); 45 $message = Filesystem::readRandomCharacters(64). 46 sprintf(' {%s} ', $file->getMonogram()); 47 48 $editor = id(new ConpherenceEditor()) 49 ->setActor($actor) 50 ->setContentSource($this->newContentSource()); 51 52 $xactions = $editor->generateTransactionsFromText( 53 $actor, 54 $conpherence, 55 $message); 56 57 return $editor->applyTransactions($conpherence, $xactions); 58 } 59 60 private function generateTestFile(PhabricatorUser $actor) { 61 $engine = new PhabricatorTestStorageEngine(); 62 $data = Filesystem::readRandomCharacters(64); 63 64 $params = array( 65 'name' => 'test.'.$actor->getPHID(), 66 'viewPolicy' => $actor->getPHID(), 67 'authorPHID' => $actor->getPHID(), 68 'storageEngines' => array( 69 $engine, 70 ), 71 ); 72 73 $file = PhabricatorFile::newFromFileData($data, $params); 74 $file->save(); 75 76 return $file; 77 } 78 79}