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:
		| @@ -100,6 +100,32 @@ final class ConpherenceRoomTestCase extends ConpherenceTestCase { | |||||||
|       $conpherence->getRecentParticipantPHIDs()); |       $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( |   private function createRoom( | ||||||
|     PhabricatorUser $creator, |     PhabricatorUser $creator, | ||||||
|     array $participant_phids) { |     array $participant_phids) { | ||||||
|   | |||||||
| @@ -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); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -86,6 +86,32 @@ final class ConpherenceThreadTestCase extends ConpherenceTestCase { | |||||||
|       $conpherence->getRecentParticipantPHIDs()); |       $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( |   private function createThread( | ||||||
|     PhabricatorUser $creator, |     PhabricatorUser $creator, | ||||||
|     array $participant_phids) { |     array $participant_phids) { | ||||||
|   | |||||||
| @@ -2,8 +2,7 @@ | |||||||
|  |  | ||||||
| final class ConpherenceNewController extends ConpherenceController { | final class ConpherenceNewController extends ConpherenceController { | ||||||
|  |  | ||||||
|   public function processRequest() { |   public function handleRequest(AphrontRequest $request) { | ||||||
|     $request = $this->getRequest(); |  | ||||||
|     $user = $request->getUser(); |     $user = $request->getUser(); | ||||||
|  |  | ||||||
|     $title = pht('New Message'); |     $title = pht('New Message'); | ||||||
|   | |||||||
| @@ -3,8 +3,7 @@ | |||||||
| final class ConpherenceNotificationPanelController | final class ConpherenceNotificationPanelController | ||||||
|   extends ConpherenceController { |   extends ConpherenceController { | ||||||
|  |  | ||||||
|   public function processRequest() { |   public function handleRequest(AphrontRequest $request) { | ||||||
|     $request = $this->getRequest(); |  | ||||||
|     $user = $request->getUser(); |     $user = $request->getUser(); | ||||||
|     $conpherences = array(); |     $conpherences = array(); | ||||||
|     $unread_status = ConpherenceParticipationStatus::BEHIND; |     $unread_status = ConpherenceParticipationStatus::BEHIND; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Bob Trahan
					Bob Trahan