3 final class ConpherenceRoomTestCase
extends ConpherenceTestCase
{
5 protected function getPhabricatorTestCaseConfiguration() {
7 self
::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES
=> true,
11 public function testOneUserRoomCreate() {
12 $creator = $this->generateNewTestUser();
13 $participant_phids = array($creator->getPHID());
15 $conpherence = $this->createRoom($creator, $participant_phids);
17 $this->assertTrue((bool)$conpherence->getID());
18 $this->assertEqual(1, count($conpherence->getParticipants()));
21 public function testNUserRoomCreate() {
22 $creator = $this->generateNewTestUser();
23 $friend_1 = $this->generateNewTestUser();
24 $friend_2 = $this->generateNewTestUser();
25 $friend_3 = $this->generateNewTestUser();
27 $participant_phids = array(
34 $conpherence = $this->createRoom($creator, $participant_phids);
36 $this->assertTrue((bool)$conpherence->getID());
37 $this->assertEqual(4, count($conpherence->getParticipants()));
40 public function testRoomParticipantAddition() {
41 $creator = $this->generateNewTestUser();
42 $friend_1 = $this->generateNewTestUser();
43 $friend_2 = $this->generateNewTestUser();
44 $friend_3 = $this->generateNewTestUser();
46 $participant_phids = array(
51 $conpherence = $this->createRoom($creator, $participant_phids);
53 $this->assertTrue((bool)$conpherence->getID());
54 $this->assertEqual(2, count($conpherence->getParticipants()));
56 // test add by creator
57 $participant_phids[] = $friend_2->getPHID();
58 $this->addParticipants($creator, $conpherence, array($friend_2->getPHID()));
59 $this->assertEqual(3, count($conpherence->getParticipants()));
61 // test add by other participant, so recent participation should
62 // meaningfully change
63 $participant_phids = array(
64 $friend_2->getPHID(), // actor
65 $creator->getPHID(), // last actor
67 $friend_3->getPHID(), // new addition
69 $this->addParticipants(
72 array($friend_3->getPHID()));
73 $this->assertEqual(4, count($conpherence->getParticipants()));
76 public function testRoomParticipantDeletion() {
77 $creator = $this->generateNewTestUser();
78 $friend_1 = $this->generateNewTestUser();
79 $friend_2 = $this->generateNewTestUser();
80 $friend_3 = $this->generateNewTestUser();
82 $participant_map = array(
83 $creator->getPHID() => $creator,
84 $friend_1->getPHID() => $friend_1,
85 $friend_2->getPHID() => $friend_2,
86 $friend_3->getPHID() => $friend_3,
89 $conpherence = $this->createRoom(
91 array_keys($participant_map));
93 foreach ($participant_map as $phid => $user) {
94 $this->removeParticipants($user, $conpherence, array($phid));
95 unset($participant_map[$phid]);
97 count($participant_map),
98 count($conpherence->getParticipants()));
102 private function createRoom(
103 PhabricatorUser
$creator,
104 array $participant_phids) {
106 $conpherence = ConpherenceThread
::initializeNewRoom($creator);
109 $xactions[] = id(new ConpherenceTransaction())
110 ->setTransactionType(
111 ConpherenceThreadParticipantsTransaction
::TRANSACTIONTYPE
)
112 ->setNewValue(array('+' => $participant_phids));
113 $xactions[] = id(new ConpherenceTransaction())
114 ->setTransactionType(
115 ConpherenceThreadTitleTransaction
::TRANSACTIONTYPE
)
116 ->setNewValue(pht('Test'));
118 id(new ConpherenceEditor())
120 ->setContentSource($this->newContentSource())
121 ->setContinueOnNoEffect(true)
122 ->applyTransactions($conpherence, $xactions);
127 private function changeEditPolicy(
128 PhabricatorUser
$actor,
129 ConpherenceThread
$room,
133 $xactions[] = id(new ConpherenceTransaction())
134 ->setTransactionType(PhabricatorTransactions
::TYPE_EDIT_POLICY
)
135 ->setNewValue($policy);
137 id(new ConpherenceEditor())
139 ->setContentSource($this->newContentSource())
140 ->setContinueOnNoEffect(true)
141 ->applyTransactions($room, $xactions);