Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / conpherence / __tests__ / ConpherenceTestCase.php
blob6c8397c7d85940986195c806589725d81fb1f6d0
1 <?php
3 abstract class ConpherenceTestCase extends PhabricatorTestCase {
5 protected function addParticipants(
6 PhabricatorUser $actor,
7 ConpherenceThread $conpherence,
8 array $participant_phids) {
10 $xactions = array(
11 id(new ConpherenceTransaction())
12 ->setTransactionType(
13 ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
14 ->setNewValue(array('+' => $participant_phids)),
16 $editor = id(new ConpherenceEditor())
17 ->setActor($actor)
18 ->setContentSource($this->newContentSource())
19 ->applyTransactions($conpherence, $xactions);
23 protected function removeParticipants(
24 PhabricatorUser $actor,
25 ConpherenceThread $conpherence,
26 array $participant_phids) {
28 $xactions = array(
29 id(new ConpherenceTransaction())
30 ->setTransactionType(
31 ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
32 ->setNewValue(array('-' => $participant_phids)),
34 $editor = id(new ConpherenceEditor())
35 ->setActor($actor)
36 ->setContentSource($this->newContentSource())
37 ->applyTransactions($conpherence, $xactions);
40 protected function addMessageWithFile(
41 PhabricatorUser $actor,
42 ConpherenceThread $conpherence) {
44 $file = $this->generateTestFile($actor);
45 $message = Filesystem::readRandomCharacters(64).
46 sprintf(' {%s} ', $file->getMonogram());
48 $editor = id(new ConpherenceEditor())
49 ->setActor($actor)
50 ->setContentSource($this->newContentSource());
52 $xactions = $editor->generateTransactionsFromText(
53 $actor,
54 $conpherence,
55 $message);
57 return $editor->applyTransactions($conpherence, $xactions);
60 private function generateTestFile(PhabricatorUser $actor) {
61 $engine = new PhabricatorTestStorageEngine();
62 $data = Filesystem::readRandomCharacters(64);
64 $params = array(
65 'name' => 'test.'.$actor->getPHID(),
66 'viewPolicy' => $actor->getPHID(),
67 'authorPHID' => $actor->getPHID(),
68 'storageEngines' => array(
69 $engine,
73 $file = PhabricatorFile::newFromFileData($data, $params);
74 $file->save();
76 return $file;