3
final class ConpherenceThreadTestCase extends ConpherenceTestCase {
5
protected function getPhabricatorTestCaseConfiguration() {
7
self::PHABRICATOR_TESTCONFIG_BUILD_STORAGE_FIXTURES => true,
11
public function testOneUserThreadCreate() {
12
$creator = $this->generateNewTestUser();
13
$participant_phids = array($creator->getPHID());
15
$conpherence = $this->createThread($creator, $participant_phids);
17
$this->assertTrue((bool)$conpherence->getID());
18
$this->assertEqual(1, count($conpherence->getParticipants()));
21
$conpherence->getRecentParticipantPHIDs());
24
public function testNUserThreadCreate() {
25
$creator = $this->generateNewTestUser();
26
$friend_1 = $this->generateNewTestUser();
27
$friend_2 = $this->generateNewTestUser();
28
$friend_3 = $this->generateNewTestUser();
30
$participant_phids = array(
37
$conpherence = $this->createThread($creator, $participant_phids);
39
$this->assertTrue((bool)$conpherence->getID());
40
$this->assertEqual(4, count($conpherence->getParticipants()));
43
$conpherence->getRecentParticipantPHIDs());
46
public function testThreadParticipantAddition() {
47
$creator = $this->generateNewTestUser();
48
$friend_1 = $this->generateNewTestUser();
49
$friend_2 = $this->generateNewTestUser();
50
$friend_3 = $this->generateNewTestUser();
52
$participant_phids = array(
57
$conpherence = $this->createThread($creator, $participant_phids);
59
$this->assertTrue((bool)$conpherence->getID());
60
$this->assertEqual(2, count($conpherence->getParticipants()));
63
$conpherence->getRecentParticipantPHIDs());
65
// test add by creator
66
$participant_phids[] = $friend_2->getPHID();
67
$this->addParticipants($creator, $conpherence, array($friend_2->getPHID()));
70
$conpherence->getRecentParticipantPHIDs());
72
// test add by other participant, so recent participation should
73
// meaningfully change
74
$participant_phids = array(
75
$friend_2->getPHID(), // actor
76
$creator->getPHID(), // last actor
78
$friend_3->getPHID(), // new addition
80
$this->addParticipants(
83
array($friend_3->getPHID()));
86
$conpherence->getRecentParticipantPHIDs());
89
public function testThreadParticipantDeletion() {
90
$creator = $this->generateNewTestUser();
91
$friend_1 = $this->generateNewTestUser();
92
$friend_2 = $this->generateNewTestUser();
93
$friend_3 = $this->generateNewTestUser();
95
$participant_map = array(
96
$creator->getPHID() => $creator,
97
$friend_1->getPHID() => $friend_1,
98
$friend_2->getPHID() => $friend_2,
99
$friend_3->getPHID() => $friend_3,
102
$conpherence = $this->createThread(
104
array_keys($participant_map));
106
foreach ($participant_map as $phid => $user) {
107
$this->removeParticipants($user, $conpherence, array($phid));
108
unset($participant_map[$phid]);
110
count($participant_map),
111
count($conpherence->getParticipants()));
115
public function testAddMessageWithFileAttachments() {
116
$creator = $this->generateNewTestUser();
117
$friend_1 = $this->generateNewTestUser();
118
$policy_exception_user = $this->generateNewTestUser();
120
$participant_map = array(
121
$creator->getPHID() => $creator,
122
$friend_1->getPHID() => $friend_1,
125
$conpherence = $this->createThread(
127
array_keys($participant_map));
129
foreach ($participant_map as $phid => $user) {
130
$xactions = $this->addMessageWithFile($user, $conpherence);
131
$this->assertEqual(2, count($xactions), pht('hi'));
136
$xactions = $this->addMessageWithFile(
137
$policy_exception_user,
139
} catch (PhabricatorPolicyException $ex) {
143
$caught instanceof PhabricatorPolicyException,
145
'User not participating in thread should get policy exception '.
146
'trying to add message.'));
148
$conpherence->establishConnection('w')->isReadLocking(),
150
'Conpherence object should still be read locked from policy '.
152
$conpherence->endReadLocking();
153
$conpherence->killTransaction();
156
private function createThread(
157
PhabricatorUser $creator,
158
array $participant_phids) {
160
list($errors, $conpherence) = ConpherenceEditor::createThread(
165
PhabricatorContentSource::newConsoleSource());