当前位置: 首页>>代码示例>>PHP>>正文


PHP Conversation::getById方法代码示例

本文整理汇总了PHP中Conversation::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Conversation::getById方法的具体用法?PHP Conversation::getById怎么用?PHP Conversation::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Conversation的用法示例。


在下文中一共展示了Conversation::getById方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSearchByType

 public function testSearchByType()
 {
     $super = User::getByUsername('super');
     $steven = User::getByUsername('steven');
     Yii::app()->user->userModel = $super;
     $conversationModel = new Conversation(false);
     $searchAttributes = array();
     $conversation = new Conversation();
     $conversation->owner = $steven;
     $conversation->subject = 'My test subject';
     $conversation->description = 'My test description';
     $this->assertTrue($conversation->save());
     $conversationId = $conversation->id;
     //Super dont have created conversations
     $metadataAdapter = new ConversationsSearchDataProviderMetadataAdapter($conversationModel, $super->id, $searchAttributes, ConversationsSearchDataProviderMetadataAdapter::LIST_TYPE_CREATED);
     $searchAttributeData = $metadataAdapter->getAdaptedMetadata();
     $dataProvider = new RedBeanModelDataProvider('Conversation', null, false, $searchAttributeData);
     $data = $dataProvider->getData();
     $this->assertEquals(0, count($data));
     //Super dont participate in any conversations
     $metadataAdapter = new ConversationsSearchDataProviderMetadataAdapter($conversationModel, $super->id, $searchAttributes, ConversationsSearchDataProviderMetadataAdapter::LIST_TYPE_PARTICIPANT);
     $searchAttributeData = $metadataAdapter->getAdaptedMetadata();
     $dataProvider = new RedBeanModelDataProvider('Conversation', null, false, $searchAttributeData);
     $data = $dataProvider->getData();
     $this->assertEquals(0, count($data));
     //Super dont participate in any closed conversations
     $metadataAdapter = new ConversationsSearchDataProviderMetadataAdapter($conversationModel, $super->id, $searchAttributes, ConversationsSearchDataProviderMetadataAdapter::LIST_TYPE_CLOSED);
     $searchAttributeData = $metadataAdapter->getAdaptedMetadata();
     $dataProvider = new RedBeanModelDataProvider('Conversation', null, false, $searchAttributeData);
     $data = $dataProvider->getData();
     $this->assertEquals(0, count($data));
     //Super participate in one conversation
     $conversation = Conversation::getById($conversationId);
     $conversationParticipant = new ConversationParticipant();
     $conversationParticipant->person = $super;
     $conversation->conversationParticipants->add($conversationParticipant);
     $this->assertTrue($conversation->save());
     $metadataAdapter = new ConversationsSearchDataProviderMetadataAdapter($conversationModel, $super->id, $searchAttributes, ConversationsSearchDataProviderMetadataAdapter::LIST_TYPE_PARTICIPANT);
     $searchAttributeData = $metadataAdapter->getAdaptedMetadata();
     $dataProvider = new RedBeanModelDataProvider('Conversation', null, false, $searchAttributeData);
     $data = $dataProvider->getData();
     $this->assertEquals(1, count($data));
     //Super participate in a closed conversation
     $conversation = Conversation::getById($conversationId);
     $conversation->isClosed = true;
     $this->assertTrue($conversation->save());
     $metadataAdapter = new ConversationsSearchDataProviderMetadataAdapter($conversationModel, $super->id, $searchAttributes, ConversationsSearchDataProviderMetadataAdapter::LIST_TYPE_CLOSED);
     $searchAttributeData = $metadataAdapter->getAdaptedMetadata();
     $dataProvider = new RedBeanModelDataProvider('Conversation', null, false, $searchAttributeData);
     $data = $dataProvider->getData();
     $this->assertEquals(1, count($data));
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:52,代码来源:ConversationsSearchWithDataProviderTest.php

示例2: testDeleteConversation

 /**
  * @depends testGetUnreadConversationCount
  */
 public function testDeleteConversation()
 {
     $conversations = Conversation::getAll();
     $this->assertEquals(3, count($conversations));
     $comments = Comment::getAll();
     $this->assertEquals(4, count($comments));
     //check count of conversation_items
     $count = ZurmoRedBean::getRow('select count(*) count from conversation_item');
     $this->assertEquals(2, $count['count']);
     //remove the account, tests tthat ConversationObserver is correctly removing data from conversation_item
     $accounts = Account::getByName('anAccount2');
     $this->assertTrue($accounts[0]->delete());
     $count = ZurmoRedBean::getRow('select count(*) count from conversation_item');
     $this->assertEquals(1, $count['count']);
     foreach ($conversations as $conversation) {
         $conversationId = $conversation->id;
         $conversation->forget();
         $conversation = Conversation::getById($conversationId);
         $deleted = $conversation->delete();
         $this->assertTrue($deleted);
     }
     //Count of conversation items should be 0 since the ConversationsObserver should make sure it gets removed correctly.
     $count = ZurmoRedBean::getRow('select count(*) count from conversation_item');
     $this->assertEquals(0, $count['count']);
     //check that all comments are removed, since they are owned.
     $comments = Comment::getAll();
     $this->assertEquals(0, count($comments));
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:31,代码来源:ConversationTest.php

示例3: testMarkReadUnreadMassActionByModel

 public function testMarkReadUnreadMassActionByModel()
 {
     $super = User::getByUsername('super');
     //Conversation model
     $conversation = new Conversation();
     $conversation->owner = $super;
     $conversation->subject = 'My test conversation subject';
     $conversation->description = 'My test conversation description';
     $this->assertTrue($conversation->save());
     $conversationId = $conversation->id;
     $this->assertTrue((bool) ConversationsUtil::hasUserReadConversationLatest($conversation, $super));
     //Mark conversation as unread
     $selectedIds = $conversationId;
     $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
     $this->setGetArray(array('ajax' => 'list-view', 'modelClassName' => 'Conversation', 'MashableInboxForm' => array('massAction' => 'markUnread', 'selectedIds' => $selectedIds)));
     $content = $this->runControllerWithNoExceptionsAndGetContent('mashableInbox/default/list');
     $conversation = Conversation::getById($conversationId);
     $this->assertFalse((bool) ConversationsUtil::hasUserReadConversationLatest($conversation, $super));
     //Mark conversation as read
     $this->setGetArray(array('ajax' => 'list-view', 'modelClassName' => 'Conversation', 'MashableInboxForm' => array('massAction' => 'markRead', 'selectedIds' => $selectedIds)));
     $content = $this->runControllerWithNoExceptionsAndGetContent('mashableInbox/default/list');
     $conversation = Conversation::getById($conversationId);
     $this->assertTrue((bool) ConversationsUtil::hasUserReadConversationLatest($conversation, $super));
     //Mission model
     $mission = new Mission();
     $mission->owner = $super;
     $mission->description = 'My test mission description';
     $mission->status = Mission::STATUS_AVAILABLE;
     $this->assertTrue($mission->save());
     $missionId = $mission->id;
     $this->assertTrue((bool) MissionsUtil::hasUserReadMissionLatest($mission, $super));
     //Mark mission as unread
     $selectedIds = $missionId;
     $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
     $this->setGetArray(array('ajax' => 'list-view', 'modelClassName' => 'Mission', 'MashableInboxForm' => array('massAction' => 'markUnread', 'selectedIds' => $selectedIds)));
     $content = $this->runControllerWithNoExceptionsAndGetContent('mashableInbox/default/list');
     $mission = Mission::getById($missionId);
     $this->assertFalse((bool) MissionsUtil::hasUserReadMissionLatest($mission, $super));
     //Mark mission as read
     $this->setGetArray(array('ajax' => 'list-view', 'modelClassName' => 'Mission', 'MashableInboxForm' => array('massAction' => 'markRead', 'selectedIds' => $selectedIds)));
     $content = $this->runControllerWithNoExceptionsAndGetContent('mashableInbox/default/list');
     $mission = Mission::getById($missionId);
     $this->assertTrue((bool) MissionsUtil::hasUserReadMissionLatest($mission, $super));
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:44,代码来源:MashableInboxUserWalkthroughTest.php

示例4: testResolveCloseSelected

 public function testResolveCloseSelected()
 {
     $super = User::getByUsername('super');
     $steven = User::getByUsername('steven');
     Yii::app()->user->userModel = $super;
     $createdConversation = $this->createAndSaveNewConversationForUser($super, $steven);
     $this->rules->resolveCloseSelected($createdConversation->id);
     $conversation = Conversation::getById($createdConversation->id);
     $this->assertTrue((bool) $conversation->isClosed);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:10,代码来源:ConversationsMashableInboxRulesTest.php

示例5: actionUpdateParticipants

 public function actionUpdateParticipants($id)
 {
     $postData = PostUtil::getData();
     if (isset($postData['ConversationParticipantsForm'])) {
         $conversation = Conversation::getById((int) $id);
         $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($conversation);
         $currentUserWasParticipant = ConversationParticipantsUtil::isUserAParticipant($conversation, Yii::app()->user->userModel);
         $peopleAdded = ConversationParticipantsUtil::resolveConversationHasManyParticipantsFromPost($conversation, $postData['ConversationParticipantsForm'], $explicitReadWriteModelPermissions);
         ConversationParticipantsUtil::resolveEmailInvitesByPeople($conversation, $peopleAdded);
         $saved = $conversation->save();
         if ($saved) {
             $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($conversation, $explicitReadWriteModelPermissions);
             $currentUserIsParticipant = ConversationParticipantsUtil::isCurrentUserAParticipant($conversation);
             if ($currentUserWasParticipant && !$currentUserIsParticipant) {
                 echo 'redirectToList';
             }
         } else {
             throw new FailedToSaveModelException();
         }
     }
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:21,代码来源:DefaultController.php

示例6: testUserEditAndDeletePermissions

 /**
  * @depends testAddingCommentsAndUpdatingActivityStampsOnConversation
  */
 public function testUserEditAndDeletePermissions()
 {
     if (!SECURITY_OPTIMIZED) {
         return;
     }
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $mary = User::getByUsername('mary');
     $conversations = Conversation::getAll();
     $this->assertEquals(1, count($conversations));
     $this->assertEquals(2, $conversations[0]->comments->count());
     //Add mary back as a participant.
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $this->setGetArray(array('id' => $conversations[0]->id));
     $this->setPostArray(array('ConversationParticipantsForm' => array('itemIds' => $mary->getClassId('Item'))));
     $this->runControllerWithNoExceptionsAndGetContent('conversations/default/updateParticipants', true);
     //new test - mary, as a participant can edit the conversation
     $mary = $this->logoutCurrentUserLoginNewUserAndGetByUsername('mary');
     $this->setGetArray(array('id' => $conversations[0]->id));
     $this->runControllerWithNoExceptionsAndGetContent('conversations/default/edit');
     //new test - mary can delete a comment she wrote
     $maryCommentId = $conversations[0]->comments->offsetGet(1)->id;
     $this->assertEquals($conversations[0]->comments->offsetGet(1)->createdByUser->id, $mary->id);
     $superCommentId = $conversations[0]->comments->offsetGet(0)->id;
     $this->assertEquals($conversations[0]->comments->offsetGet(0)->createdByUser->id, $super->id);
     $this->setGetArray(array('relatedModelId' => $conversations[0]->id, 'relatedModelClassName' => 'Conversation', 'relatedModelRelationName' => 'comments', 'id' => $maryCommentId));
     $this->runControllerWithNoExceptionsAndGetContent('comments/default/deleteViaAjax', true);
     $conversationId = $conversations[0]->id;
     $conversations[0]->forget();
     $conversation = Conversation::getById($conversationId);
     $this->assertEquals(1, $conversation->comments->count());
     //new test - mary cannot delete a comment she did not write.
     $this->setGetArray(array('relatedModelId' => $conversations[0]->id, 'relatedModelClassName' => 'Conversation', 'relatedModelRelationName' => 'comments', 'id' => $superCommentId));
     $this->runControllerShouldResultInAjaxAccessFailureAndGetContent('comments/default/deleteViaAjax');
     $conversationId = $conversations[0]->id;
     $conversations[0]->forget();
     $conversation = Conversation::getById($conversationId);
     $this->assertEquals(1, $conversation->comments->count());
     $this->assertEquals(1, $conversation->comments->count());
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //new test , super can view and edit the conversation
     $this->setGetArray(array('id' => $conversation->id));
     $this->runControllerWithNoExceptionsAndGetContent('conversations/default/details');
     $this->runControllerWithNoExceptionsAndGetContent('conversations/default/edit');
     //new test , super can delete the conversation
     $this->setGetArray(array('id' => $conversation->id));
     $this->runControllerWithRedirectExceptionAndGetContent('conversations/default/delete');
     $conversations = Conversation::getAll();
     $this->assertEquals(0, count($conversations));
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:52,代码来源:ConversationsUserWalkthroughTest.php

示例7: testMarkUserHasReadLatest

 public function testMarkUserHasReadLatest()
 {
     $super = User::getByUsername('super');
     $steven = UserTestHelper::createBasicUser('steven');
     $conversation = new Conversation();
     $conversation->owner = $super;
     $conversation->subject = 'My test subject';
     $conversation->description = 'My test description';
     $this->assertTrue($conversation->save());
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($conversation);
     $postData = array();
     $postData['itemIds'] = $steven->getClassId('Item');
     ConversationParticipantsUtil::resolveConversationHasManyParticipantsFromPost($conversation, $postData, $explicitReadWriteModelPermissions);
     $this->assertTrue($conversation->save());
     $success = ExplicitReadWriteModelPermissionsUtil::resolveExplicitReadWriteModelPermissions($conversation, $explicitReadWriteModelPermissions);
     $this->assertTrue($success);
     $id = $conversation->id;
     $conversation->forget();
     unset($conversation);
     $conversation = Conversation::getById($id);
     $this->assertEquals(1, $conversation->ownerHasReadLatest);
     $this->assertEquals(0, $conversation->conversationParticipants->offsetGet(0)->hasReadLatest);
     //After running for super, nothing will change.
     ConversationsUtil::markUserHasReadLatest($conversation, $super);
     $id = $conversation->id;
     $conversation->forget();
     unset($conversation);
     $conversation = Conversation::getById($id);
     $this->assertEquals(1, $conversation->ownerHasReadLatest);
     $this->assertEquals(0, $conversation->conversationParticipants->offsetGet(0)->hasReadLatest);
     //After running for steven, it will show read for him.
     ConversationsUtil::markUserHasReadLatest($conversation, $steven);
     $id = $conversation->id;
     $conversation->forget();
     unset($conversation);
     $conversation = Conversation::getById($id);
     $this->assertEquals(1, $conversation->ownerHasReadLatest);
     $this->assertEquals(1, $conversation->conversationParticipants->offsetGet(0)->hasReadLatest);
     $conversation->ownerHasReadLatest = false;
     $this->assertTrue($conversation->save());
     $id = $conversation->id;
     $conversation->forget();
     unset($conversation);
     $conversation = Conversation::getById($id);
     $this->assertEquals(0, $conversation->ownerHasReadLatest);
     $this->assertEquals(1, $conversation->conversationParticipants->offsetGet(0)->hasReadLatest);
     //Now try for Steven, nothing changes
     ConversationsUtil::markUserHasReadLatest($conversation, $steven);
     $id = $conversation->id;
     $conversation->forget();
     unset($conversation);
     $conversation = Conversation::getById($id);
     $this->assertEquals(0, $conversation->ownerHasReadLatest);
     $this->assertEquals(1, $conversation->conversationParticipants->offsetGet(0)->hasReadLatest);
     //Now try for super, should change
     ConversationsUtil::markUserHasReadLatest($conversation, $super);
     $id = $conversation->id;
     $conversation->forget();
     unset($conversation);
     $conversation = Conversation::getById($id);
     $this->assertEquals(1, $conversation->ownerHasReadLatest);
     $this->assertEquals(1, $conversation->conversationParticipants->offsetGet(0)->hasReadLatest);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:63,代码来源:ConversationsUtilTest.php


注:本文中的Conversation::getById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。