1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-11 03:44:48 +01:00

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
This commit is contained in:
Bob Trahan 2015-03-26 16:46:47 -07:00
parent 39fa190c15
commit 22501ab31e
5 changed files with 69 additions and 4 deletions

View file

@ -100,6 +100,32 @@ final class ConpherenceRoomTestCase extends ConpherenceTestCase {
$conpherence->getRecentParticipantPHIDs());
}
public function testRoomParticipantDeletion() {
$creator = $this->generateNewTestUser();
$friend_1 = $this->generateNewTestUser();
$friend_2 = $this->generateNewTestUser();
$friend_3 = $this->generateNewTestUser();
$participant_map = array(
$creator->getPHID() => $creator,
$friend_1->getPHID() => $friend_1,
$friend_2->getPHID() => $friend_2,
$friend_3->getPHID() => $friend_3,
);
$conpherence = $this->createRoom(
$creator,
array_keys($participant_map));
foreach ($participant_map as $phid => $user) {
$this->removeParticipants($user, $conpherence, array($phid));
unset($participant_map[$phid]);
$this->assertEqual(
count($participant_map),
count($conpherence->getParticipants()));
}
}
private function createRoom(
PhabricatorUser $creator,
array $participant_phids) {

View file

@ -17,4 +17,19 @@ abstract class ConpherenceTestCase extends PhabricatorTestCase {
}
protected function removeParticipants(
PhabricatorUser $actor,
ConpherenceThread $conpherence,
array $participant_phids) {
$xactions = array(id(new ConpherenceTransaction())
->setTransactionType(ConpherenceTransactionType::TYPE_PARTICIPANTS)
->setNewValue(array('-' => $participant_phids)),);
$editor = id(new ConpherenceEditor())
->setActor($actor)
->setContentSource(PhabricatorContentSource::newConsoleSource())
->applyTransactions($conpherence, $xactions);
}
}

View file

@ -86,6 +86,32 @@ final class ConpherenceThreadTestCase extends ConpherenceTestCase {
$conpherence->getRecentParticipantPHIDs());
}
public function testThreadParticipantDeletion() {
$creator = $this->generateNewTestUser();
$friend_1 = $this->generateNewTestUser();
$friend_2 = $this->generateNewTestUser();
$friend_3 = $this->generateNewTestUser();
$participant_map = array(
$creator->getPHID() => $creator,
$friend_1->getPHID() => $friend_1,
$friend_2->getPHID() => $friend_2,
$friend_3->getPHID() => $friend_3,
);
$conpherence = $this->createThread(
$creator,
array_keys($participant_map));
foreach ($participant_map as $phid => $user) {
$this->removeParticipants($user, $conpherence, array($phid));
unset($participant_map[$phid]);
$this->assertEqual(
count($participant_map),
count($conpherence->getParticipants()));
}
}
private function createThread(
PhabricatorUser $creator,
array $participant_phids) {

View file

@ -2,8 +2,7 @@
final class ConpherenceNewController extends ConpherenceController {
public function processRequest() {
$request = $this->getRequest();
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$title = pht('New Message');

View file

@ -3,8 +3,7 @@
final class ConpherenceNotificationPanelController
extends ConpherenceController {
public function processRequest() {
$request = $this->getRequest();
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$conpherences = array();
$unread_status = ConpherenceParticipationStatus::BEHIND;