Skip to content

Commit 22501ab

Browse files
committed
Conpherence - unit tests for T7670
Summary: Ref T7670. Add a few unit tests to make sure deleting everyone works. Also change remaining processRequest to handleRequest while in there. Test Plan: `arc unit` passed Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7670 Differential Revision: https://secure.phabricator.com/D12179
1 parent 39fa190 commit 22501ab

File tree

5 files changed

+69
-4
lines changed

5 files changed

+69
-4
lines changed

src/applications/conpherence/__tests__/ConpherenceRoomTestCase.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,32 @@ public function testRoomParticipantAddition() {
100100
$conpherence->getRecentParticipantPHIDs());
101101
}
102102

103+
public function testRoomParticipantDeletion() {
104+
$creator = $this->generateNewTestUser();
105+
$friend_1 = $this->generateNewTestUser();
106+
$friend_2 = $this->generateNewTestUser();
107+
$friend_3 = $this->generateNewTestUser();
108+
109+
$participant_map = array(
110+
$creator->getPHID() => $creator,
111+
$friend_1->getPHID() => $friend_1,
112+
$friend_2->getPHID() => $friend_2,
113+
$friend_3->getPHID() => $friend_3,
114+
);
115+
116+
$conpherence = $this->createRoom(
117+
$creator,
118+
array_keys($participant_map));
119+
120+
foreach ($participant_map as $phid => $user) {
121+
$this->removeParticipants($user, $conpherence, array($phid));
122+
unset($participant_map[$phid]);
123+
$this->assertEqual(
124+
count($participant_map),
125+
count($conpherence->getParticipants()));
126+
}
127+
}
128+
103129
private function createRoom(
104130
PhabricatorUser $creator,
105131
array $participant_phids) {

src/applications/conpherence/__tests__/ConpherenceTestCase.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,19 @@ protected function addParticipants(
1717

1818
}
1919

20+
protected function removeParticipants(
21+
PhabricatorUser $actor,
22+
ConpherenceThread $conpherence,
23+
array $participant_phids) {
24+
25+
$xactions = array(id(new ConpherenceTransaction())
26+
->setTransactionType(ConpherenceTransactionType::TYPE_PARTICIPANTS)
27+
->setNewValue(array('-' => $participant_phids)),);
28+
$editor = id(new ConpherenceEditor())
29+
->setActor($actor)
30+
->setContentSource(PhabricatorContentSource::newConsoleSource())
31+
->applyTransactions($conpherence, $xactions);
32+
}
33+
34+
2035
}

src/applications/conpherence/__tests__/ConpherenceThreadTestCase.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,32 @@ public function testThreadParticipantAddition() {
8686
$conpherence->getRecentParticipantPHIDs());
8787
}
8888

89+
public function testThreadParticipantDeletion() {
90+
$creator = $this->generateNewTestUser();
91+
$friend_1 = $this->generateNewTestUser();
92+
$friend_2 = $this->generateNewTestUser();
93+
$friend_3 = $this->generateNewTestUser();
94+
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,
100+
);
101+
102+
$conpherence = $this->createThread(
103+
$creator,
104+
array_keys($participant_map));
105+
106+
foreach ($participant_map as $phid => $user) {
107+
$this->removeParticipants($user, $conpherence, array($phid));
108+
unset($participant_map[$phid]);
109+
$this->assertEqual(
110+
count($participant_map),
111+
count($conpherence->getParticipants()));
112+
}
113+
}
114+
89115
private function createThread(
90116
PhabricatorUser $creator,
91117
array $participant_phids) {

src/applications/conpherence/controller/ConpherenceNewController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
final class ConpherenceNewController extends ConpherenceController {
44

5-
public function processRequest() {
6-
$request = $this->getRequest();
5+
public function handleRequest(AphrontRequest $request) {
76
$user = $request->getUser();
87

98
$title = pht('New Message');

src/applications/conpherence/controller/ConpherenceNotificationPanelController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
final class ConpherenceNotificationPanelController
44
extends ConpherenceController {
55

6-
public function processRequest() {
7-
$request = $this->getRequest();
6+
public function handleRequest(AphrontRequest $request) {
87
$user = $request->getUser();
98
$conpherences = array();
109
$unread_status = ConpherenceParticipationStatus::BEHIND;

0 commit comments

Comments
 (0)