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


PHP ContactTestHelper::createContactByNameForOwner方法代码示例

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


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

示例1: resolveEmailMessage

 protected function resolveEmailMessage($subject = 'Subject', $textContent = 'My First Message', $htmlContent = 'Some fake HTML content', $fromAddress = 'zurmo@zurmo.org', $fromName = 'Zurmo', $toAddress = 'bob.message@zurmotest.com', $toName = null, $contact = null)
 {
     if (!isset($contact)) {
         $contact = ContactTestHelper::createContactByNameForOwner('emailContact', Yii::app()->user->userModel);
     }
     $emailMessage = new EmailMessage();
     $emailMessage->owner = $contact->owner;
     $emailMessage->subject = $subject;
     $emailContent = new EmailMessageContent();
     $emailContent->textContent = $textContent;
     $emailContent->htmlContent = $htmlContent;
     $emailMessage->content = $emailContent;
     $sender = new EmailMessageSender();
     $sender->fromAddress = $fromAddress;
     $sender->fromName = $fromName;
     $sender->personsOrAccounts->add(Yii::app()->user->userModel);
     $emailMessage->sender = $sender;
     $recipient = new EmailMessageRecipient();
     $recipient->toAddress = $toAddress;
     if (!isset($toName)) {
         $toName = strval($contact);
     }
     $recipient->toName = $toName;
     $recipient->personsOrAccounts->add($contact);
     $recipient->type = EmailMessageRecipient::TYPE_TO;
     $emailMessage->recipients->add($recipient);
     $emailBox = EmailBoxUtil::getDefaultEmailBoxByUser(Yii::app()->user->userModel);
     $emailMessage->folder = EmailFolder::getByBoxAndType($emailBox, EmailFolder::TYPE_OUTBOX);
     $saved = $emailMessage->save();
     if (!$saved) {
         var_dump($emailMessage->getErrors());
         throw new FailedToSaveModelException();
     }
     return $emailMessage;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:35,代码来源:AutoresponderOrCampaignBaseTest.php

示例2: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     SecurityTestHelper::createUsers();
     $super = User::getByUsername('super');
     $super->primaryEmail->emailAddress = 'super@zurmo.org';
     $saved = $super->save();
     if (!$saved) {
         throw new FailedToSaveModelException();
     }
     MarketingListTestHelper::createMarketingListByName('testMarketingList');
     $campaign = CampaignTestHelper::createCampaign('testCampaign', 'testSubject', 'testContent', 'testHtmlContent');
     $contact = ContactTestHelper::createContactByNameForOwner('test', $super);
     $emailMessage = EmailMessageTestHelper::createArchivedUnmatchedSentMessage($super);
     $campaignItem = new CampaignItem();
     $campaignItem->contact = $contact;
     $campaignItem->processed = true;
     $campaignItem->campaign = $campaign;
     $campaignItem->emailMessage = $emailMessage;
     $campaignItem->unrestrictedSave();
     if (!$saved) {
         throw new FailedToSaveModelException();
     }
     AllPermissionsOptimizationUtil::rebuild();
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:26,代码来源:CampaignItemSummaryListViewColumnAdapterTest.php

示例3: testSuperUserGlobalList

 public function testSuperUserGlobalList()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //Test if actionGlobalList return a list view for all modules
     $this->setGetArray(array('MixedModelsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'term' => 't')));
     $this->resetPostArray();
     $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/globallist');
     $this->assertContains('<div class="cgrid-view type-accounts" id="list-view-accounts">', $content);
     $this->assertContains('<div class="cgrid-view type-contacts" id="list-view-contacts">', $content);
     $this->assertContains('<div class="cgrid-view type-leads" id="list-view-leads">', $content);
     $this->assertContains('<div class="cgrid-view type-opportunities" id="list-view-opportunities">', $content);
     //Even if there are results it should return a cgridview with no text
     $this->assertNotContains('No results found.', $content);
     //Test if actionGlobalList only show the module requested
     ContactTestHelper::createContactByNameForOwner('tim', $super);
     $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
     $this->setGetArray(array('MixedModelsSearchForm' => array('term' => 'd'), 'ajax' => 'list-view-accounts'));
     $this->resetPostArray();
     $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/globallist');
     $this->assertContains('id="AccountsForMixedModelsSearchListView"', $content);
     $this->assertNotContains('id="ContactsForMixedModelsSearchListView"', $content);
     $this->assertNotContains('id="LeadsForMixedModelsSearchListView"', $content);
     $this->assertNotContains('id="OpportunitiesForMixedModelsSearchListView">', $content);
     //TODO: Should test if the accounts created is shown
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:25,代码来源:ZurmoMixedModelsSearchSuperUserWalkthroughTest.php

示例4: testCreateAddAndSaveAndRemoveByIndexRelatedModels

 public function testCreateAddAndSaveAndRemoveByIndexRelatedModels()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $user = UserTestHelper::createBasicUser('Billy');
     $account = new Account();
     $account->owner = $user;
     $account->name = 'Wibble Corp';
     $this->assertTrue($account->save());
     for ($i = 0; $i < self::CONTACTS; $i++) {
         $contact = ContactTestHelper::createContactByNameForOwner('sampleContact' . $i, Yii::app()->user->userModel);
         $account->contacts->add($contact);
     }
     $this->assertTrue($account->save());
     $contact = $account->contacts[0];
     $this->assertFalse($account->isModified());
     $this->assertFalse($contact->isModified());
     $this->assertTrue($account->save());
     $this->assertFalse($account->isModified());
     $this->assertFalse($contact->isModified());
     $accountId = $account->id;
     unset($account);
     $account = Account::getById($accountId);
     $this->assertEquals('Wibble Corp', $account->name);
     $this->assertEquals(self::CONTACTS, $account->contacts->count());
     $this->assertEquals("{$account->contacts->count()} records.", strval($account->contacts));
     $contact = $account->contacts[0];
     $description = $contact->description;
     $contact->description = "this is a contact";
     $this->assertTrue($account->isModified());
     $this->assertTrue($contact->isModified());
     $this->assertTrue($account->save());
     $this->assertFalse($account->isModified());
     $this->assertFalse($contact->isModified());
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:34,代码来源:RedBeanRelatedModelsTest.php

示例5: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $user = UserTestHelper::createBasicUser('steve');
     $user->primaryEmail->emailAddress = 'steve@example.com';
     $user->setRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS);
     assert($user->save());
     // Not Coding Standard
     $contact1 = ContactTestHelper::createContactByNameForOwner('peter', $user);
     $contact1->primaryEmail->emailAddress = 'peter@example.com';
     $contact1->secondaryEmail->emailAddress = 'peter2@example.com';
     assert($contact1->save());
     // Not Coding Standard
     $contactsOrLeads = ContactSearch::getContactsByAnyEmailAddress('peter@example.com', null, null);
     $contact2 = ContactTestHelper::createContactByNameForOwner('jim', $user);
     $contact2->primaryEmail->emailAddress = 'jim@example.com';
     assert($contact2->save());
     // Not Coding Standard
     $nonExistingUserEmail = 'jill@example.com';
     self::$user = $user;
     self::$contact1 = $contact1;
     self::$contact2 = $contact2;
     self::$nonExistingUserEmail = $nonExistingUserEmail;
     Yii::app()->imap->imapUsername = 'dropbox@example.com';
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:26,代码来源:EmailArchivingJobDocumentationTest.php

示例6: testSuperUserThatContactsAndLeadsShowZeroModelUserInterfaceCorrectly

 public function testSuperUserThatContactsAndLeadsShowZeroModelUserInterfaceCorrectly()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $this->assertEquals(0, Contact::getCount());
     //At this point the zero model ui should show up for contacts and leads
     $content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/list');
     $this->assertContains('Arthur Conan', $content);
     $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/list');
     $this->assertContains('Thomas Paine', $content);
     $contact = ContactTestHelper::createContactByNameForOwner('Jimmy', $super);
     //At this point leads should still show the zero model message
     $content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/list');
     $this->assertNotContains('Arthur Conan', $content);
     $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/list');
     $this->assertContains('Thomas Paine', $content);
     $this->assertTrue($contact->delete());
     $this->assertEquals(0, Contact::getCount());
     //Create lead.
     $lead = LeadTestHelper::createLeadByNameForOwner('Jammy', $super);
     //At this point contacts should still show the zero model message
     $content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/list');
     $this->assertContains('Arthur Conan', $content);
     $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/list');
     $this->assertNotContains('Thomas Paine', $content);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:25,代码来源:ContactsSuperUserZeroModelsWalkthroughTest.php

示例7: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = User::getByUsername('super');
     ReadPermissionsOptimizationUtil::rebuild();
     SecurityTestHelper::createUsers();
     $billy = User::getByUsername('billy');
     EmailMessageTestHelper::createEmailAccount($billy);
     $billy->setRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS);
     $billy->setRight('ContactsModule', ContactsModule::RIGHT_CREATE_CONTACTS);
     $billy->setRight('ContactsModule', ContactsModule::RIGHT_DELETE_CONTACTS);
     assert($billy->save());
     // Not Coding Standard
     $contact = ContactTestHelper::createContactByNameForOwner('sally', Yii::app()->user->userModel);
     $contact->primaryEmail = new Email();
     $contact->primaryEmail->emailAddress = 'sally@zurmoland.com';
     $contact->secondaryEmail->emailAddress = 'toMakeSureNoFreeze@works.com';
     $contact->addPermissions($billy, Permission::READ);
     $contact->addPermissions($billy, Permission::WRITE);
     $contact->save();
     $molly = ContactTestHelper::createContactByNameForOwner('molly', User::getByUsername('bobby'));
     $molly->primaryEmail = new Email();
     $molly->primaryEmail->emailAddress = 'molly@zurmoland.com';
     $molly->secondaryEmail->emailAddress = 'toMakeSureNoFreeze@works.zur';
     $contact->save();
     ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($contact, $billy);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:28,代码来源:EmailMessageUtilTest.php

示例8: testResolveModelUrl

 /**
  * @depends testIsSpecialMergeTag
  */
 public function testResolveModelUrl()
 {
     $contact = ContactTestHelper::createContactByNameForOwner('contact 01', Yii::app()->user->userModel);
     $resolvedModelUrl = SpecialMergeTagsAdapter::resolve('modelUrl', $contact);
     $this->assertNotNull($resolvedModelUrl);
     $expectedSuffix = '/contacts/default/details?id=' . $contact->id;
     $this->assertContains($expectedSuffix, $resolvedModelUrl);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:11,代码来源:SpecialMergeTagsAdapterTest.php

示例9: testRenderCorrectStateTranslationAfterCallingContactStateLabel

 public function testRenderCorrectStateTranslationAfterCallingContactStateLabel()
 {
     $super = User::getByUsername('super');
     $contact = ContactTestHelper::createContactByNameForOwner('test', $super);
     ZurmoHtml::activeLabel($contact, 'state');
     $element = new AddressElement($contact, 'primaryAddress', new ZurmoActiveForm());
     $this->assertContains('<label for="Contact_primaryAddress_state">State</label>', $element->render());
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:8,代码来源:AddressElementTest.php

示例10: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $emailBox = EmailBoxUtil::getDefaultEmailBoxByUser(User::getByUsername('super'));
     ContactTestHelper::createContactByNameForOwner('contact01', Yii::app()->user->userModel);
     ContactTestHelper::createContactByNameForOwner('contact02', Yii::app()->user->userModel);
     ContactTestHelper::createContactByNameForOwner('contact03', Yii::app()->user->userModel);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:9,代码来源:MarketingEmailsInThisListChartDataProviderTest.php

示例11: testCreateEmailMessage

 public function testCreateEmailMessage()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $authenticationData = $this->login();
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     // Test with at least one existing recipient
     $data['subject'] = 'Test 1 Subject';
     $data['textContent'] = 'Test 1 Text Content';
     $data['htmlContent'] = 'Test 1 Html Content';
     $data['sentFrom']['email'] = 'senderTest@example.com';
     $data['recipients'] = array('to' => array(array('name' => 'TO1', 'email' => 'to1@example.com'), array('name' => 'TO2', 'email' => 'to2@example.com')), 'cc' => array(array('name' => 'CC1', 'email' => 'cc1@example.com'), array('name' => 'CC2', 'email' => 'cc2@example.com')));
     $contact1 = ContactTestHelper::createContactByNameForOwner('TestContact1', $super);
     $contact1->primaryEmail->emailAddress = 'to1@example.com';
     $contact1->save();
     $response = $this->createApiCallWithRelativeUrl('create/', 'POST', $headers, array('data' => $data));
     $response = json_decode($response, true);
     $this->assertArrayHasKey('id', $response['data']);
     $emailMessageId = $response['data']['id'];
     $emailMessage = EmailMessage::getById($emailMessageId);
     $this->assertEquals('Test 1 Subject', $emailMessage->subject);
     $this->assertEquals('Test 1 Text Content', $emailMessage->content->textContent);
     $this->assertEquals('Test 1 Html Content', $emailMessage->content->htmlContent);
     $this->assertEquals('senderTest@example.com', $emailMessage->sender->fromAddress);
     $this->assertEquals(EmailFolder::TYPE_ARCHIVED, $emailMessage->folder->type);
     $this->assertEquals(4, count($emailMessage->recipients));
     $this->assertEquals($data['recipients']['to'][0]['email'], $emailMessage->recipients[0]->toAddress);
     $this->assertEquals($data['recipients']['to'][0]['name'], $emailMessage->recipients[0]->toName);
     $this->assertEquals(EmailMessageRecipient::TYPE_TO, $emailMessage->recipients[0]->type);
     $this->assertEquals($data['recipients']['to'][1]['email'], $emailMessage->recipients[1]->toAddress);
     $this->assertEquals($data['recipients']['to'][1]['name'], $emailMessage->recipients[1]->toName);
     $this->assertEquals(EmailMessageRecipient::TYPE_TO, $emailMessage->recipients[1]->type);
     $this->assertEquals($data['recipients']['cc'][0]['email'], $emailMessage->recipients[2]->toAddress);
     $this->assertEquals($data['recipients']['cc'][0]['name'], $emailMessage->recipients[2]->toName);
     $this->assertEquals(EmailMessageRecipient::TYPE_CC, $emailMessage->recipients[2]->type);
     $this->assertEquals($data['recipients']['cc'][1]['email'], $emailMessage->recipients[3]->toAddress);
     $this->assertEquals($data['recipients']['cc'][1]['name'], $emailMessage->recipients[3]->toName);
     $this->assertEquals(EmailMessageRecipient::TYPE_CC, $emailMessage->recipients[3]->type);
     // Test without existing recipient
     $data['subject'] = 'Test 2 Subject';
     $data['textContent'] = 'Test 2 Text Content';
     $data['htmlContent'] = 'Test 2 Html Content';
     $data['sentFrom']['email'] = 'senderTest@example.com';
     $data['recipients'] = array('to' => array(array('name' => 'TO11', 'email' => 'to11@example.com'), array('name' => 'TO21', 'email' => 'to21@example.com')));
     $response = $this->createApiCallWithRelativeUrl('create/', 'POST', $headers, array('data' => $data));
     $response = json_decode($response, true);
     $this->assertArrayHasKey('id', $response['data']);
     $emailMessageId = $response['data']['id'];
     $emailMessage = EmailMessage::getById($emailMessageId);
     $this->assertEquals('Test 2 Subject', $emailMessage->subject);
     $this->assertEquals('Test 2 Text Content', $emailMessage->content->textContent);
     $this->assertEquals('Test 2 Html Content', $emailMessage->content->htmlContent);
     $this->assertEquals('senderTest@example.com', $emailMessage->sender->fromAddress);
     $this->assertEquals(EmailFolder::TYPE_ARCHIVED_UNMATCHED, $emailMessage->folder->type);
     $this->assertEquals(2, count($emailMessage->recipients));
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:56,代码来源:ApiRestEmailMessageTest.php

示例12: testRun

 /**
  * Test sending an email that should go out as a processing that this job would typically do.
  * Also tests that item does not get trashed when deleting the WorkflowMessageInQueue.
  * Also tests that if there is more than one emailmessage against the workflow, that it does not send
  * to all of them
  * @depends testWorkflowMessageInQueueProperlySavesWithoutTrashingRelatedModelItem
  */
 public function testRun()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $emailTemplate = new EmailTemplate();
     $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_PASTED_HTML;
     $emailTemplate->name = 'the name';
     $emailTemplate->modelClassName = 'Account';
     $emailTemplate->type = 2;
     $emailTemplate->subject = 'subject';
     $emailTemplate->textContent = 'sample text content';
     $saved = $emailTemplate->save();
     $this->assertTrue($saved);
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $model = ContactTestHelper::createContactByNameForOwner('Jason', Yii::app()->user->userModel);
     $model->primaryEmail->emailAddress = 'jason@zurmoland.com';
     $saved = $model->save();
     $this->assertTrue($saved);
     $modelId = $model->id;
     $model->forget();
     $model = Contact::getById($modelId);
     $trigger = array('attributeIndexOrDerivedType' => 'firstName', 'operator' => OperatorRules::TYPE_EQUALS, 'durationInterval' => '333');
     $actions = array(array('type' => ActionForWorkflowForm::TYPE_UPDATE_SELF, ActionForWorkflowForm::ACTION_ATTRIBUTES => array('description' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'some new description'))));
     $emailMessages = array();
     $emailMessages[0]['emailTemplateId'] = $emailTemplate->id;
     $emailMessages[0]['sendFromType'] = EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
     $emailMessages[0]['sendAfterDurationSeconds'] = '0';
     $emailMessages[0][EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS] = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL, 'audienceType' => EmailMessageRecipient::TYPE_TO));
     $emailMessages[1]['emailTemplateId'] = $emailTemplate->id;
     $emailMessages[1]['sendFromType'] = EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
     $emailMessages[1]['sendAfterDurationSeconds'] = '10000';
     $emailMessages[1][EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS] = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL, 'audienceType' => EmailMessageRecipient::TYPE_TO));
     $savedWorkflow = new SavedWorkflow();
     $savedWorkflow->name = 'some workflow';
     $savedWorkflow->description = 'description';
     $savedWorkflow->moduleClassName = 'ContactsModule';
     $savedWorkflow->triggerOn = Workflow::TRIGGER_ON_NEW_AND_EXISTING;
     $savedWorkflow->type = Workflow::TYPE_ON_SAVE;
     $data[ComponentForWorkflowForm::TYPE_TRIGGERS] = array($trigger);
     $data[ComponentForWorkflowForm::TYPE_ACTIONS] = $actions;
     $data[ComponentForWorkflowForm::TYPE_EMAIL_MESSAGES] = $emailMessages;
     $savedWorkflow->serializedData = serialize($data);
     $savedWorkflow->isActive = true;
     $saved = $savedWorkflow->save();
     $this->assertTrue($saved);
     WorkflowTestHelper::createExpiredWorkflowMessageInQueue($model, $savedWorkflow, serialize(array($emailMessages[1])));
     RedBeanModelsCache::forgetAll(true);
     //simulates page change, required to confirm Item does not get trashed
     $this->assertEquals(1, WorkflowMessageInQueue::getCount());
     $job = new WorkflowMessageInQueueJob();
     $this->assertTrue($job->run());
     $this->assertEquals(0, WorkflowMessageInQueue::getCount());
     RedBeanModelsCache::forgetAll(true);
     //simulates page change, required to confirm Item does not get trashed
     $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:62,代码来源:WorkflowMessageInQueueJobTest.php

示例13: testDownCasts

 public function testDownCasts()
 {
     $possibleDerivationPaths = array(array('SecurableItem', 'OwnedSecurableItem', 'Account'), array('SecurableItem', 'OwnedSecurableItem', 'Person', 'Contact'), array('SecurableItem', 'OwnedSecurableItem', 'Opportunity'));
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $account = AccountTestHelper::createAccountByNameForOwner('Waggle', $super);
     $contact = ContactTestHelper::createContactByNameForOwner('Noddy', $super);
     $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('Noddy', $super);
     $accountItem = Item::getById($account->getClassId('Item'));
     $contactItem = Item::getById($contact->getClassId('Item'));
     $opportunityItem = Item::getById($opportunity->getClassId('Item'));
     $this->assertTrue($accountItem->isSame($account));
     $this->assertTrue($contactItem->isSame($contact));
     $this->assertTrue($opportunityItem->isSame($opportunity));
     $this->assertFalse($accountItem instanceof Account);
     $this->assertFalse($contactItem instanceof Contact);
     $this->assertFalse($opportunityItem instanceof Opportunity);
     $account2 = $accountItem->castDown($possibleDerivationPaths);
     $this->assertEquals('Account', get_class($account2));
     //Demonstrate a single array, making sure it casts down properly.
     $accountItem2 = Item::getById($account->getClassId('Item'));
     $account3 = $accountItem2->castDown(array(array('SecurableItem', 'OwnedSecurableItem', 'Account')));
     $this->assertEquals('Account', get_class($account3));
     $contact2 = $contactItem->castDown($possibleDerivationPaths);
     $opportunity2 = $opportunityItem->castDown($possibleDerivationPaths);
     $this->assertTrue($account2->isSame($account));
     $this->assertTrue($contact2->isSame($contact));
     $this->assertTrue($opportunity2->isSame($opportunity));
     $this->assertTrue($account2 instanceof Account);
     $this->assertTrue($contact2 instanceof Contact);
     $this->assertTrue($opportunity2 instanceof Opportunity);
     $account2 = AccountTestHelper::createAccountByNameForOwner('Waggle2', $super);
     //By adding a second contact with a relation to the account2, we can demonstrate a bug with how castDown works.
     //Since contacts can in fact be attached to accounts via account_id, if a contact exists connected to the account
     //we are trying to cast down, then this will cast down even though it shouldn't.
     $contact2 = ContactTestHelper::createContactWithAccountByNameForOwner('MrWaggle2', $super, $account2);
     try {
         $account2CastedDown = $account2->castDown(array(array('SecurableItem', 'OwnedSecurableItem', 'Person', 'Contact')));
         $this->fail();
     } catch (NotFoundException $e) {
         //success
     }
     //Now try to forget the account and retrieve it.
     $account2Id = $account2->id;
     $account2->forget();
     unset($account2);
     $account2 = Account::getById($account2Id);
     try {
         $account2CastedDown = $account2->castDown(array(array('SecurableItem', 'OwnedSecurableItem', 'Person', 'Contact')));
         $this->fail();
     } catch (NotFoundException $e) {
         //success
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:54,代码来源:ActivityTest.php

示例14: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     Currency::makeBaseCurrency();
     //Setup test data owned by the super user.
     self::$account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
     self::$contact = ContactTestHelper::createContactByNameForOwner('superContact2', $super);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:11,代码来源:AccountContactAffiliationsDesignerSuperUserWalkthroughTest.php

示例15: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     //Setup test data owned by the super user.
     $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
     $contact = ContactTestHelper::createContactWithAccountByNameForOwner('superContact', $super, $account);
     $contactWithNoAccount = ContactTestHelper::createContactByNameForOwner('noAccountContact', $super);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:11,代码来源:AccountsSuperUserUnlinkWalkthroughTest.php


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