public function testCreateAndGetMissionById() { $super = User::getByUsername('super'); $fileModel = ZurmoTestHelper::createFileModel(); $steven = UserTestHelper::createBasicUser('steven'); $dueStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 10000); $mission = new Mission(); $mission->owner = $super; $mission->takenByUser = $steven; $mission->dueDateTime = $dueStamp; $mission->description = 'My test description'; $mission->reward = 'My test reward'; $mission->status = Mission::STATUS_AVAILABLE; $mission->files->add($fileModel); $mission->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE); $this->assertTrue($mission->save()); $id = $mission->id; $mission->forget(); unset($mission); $mission = Mission::getById($id); $this->assertEquals('My test description', $mission->description); $this->assertEquals('My test reward', $mission->reward); $this->assertEquals(Mission::STATUS_AVAILABLE, $mission->status); $this->assertEquals($super, $mission->owner); $this->assertEquals($steven, $mission->takenByUser); $this->assertEquals(1, $mission->files->count()); $this->assertEquals($fileModel, $mission->files->offsetGet(0)); $this->assertEquals($dueStamp, $mission->dueDateTime); $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $super)); $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $steven)); }
public function testCreateAndGetSocialItemById() { $super = User::getByUsername('super'); $fileModel = ZurmoTestHelper::createFileModel(); $accounts = Account::getByName('anAccount'); $steven = UserTestHelper::createBasicUser('steven'); $note = NoteTestHelper::createNoteWithOwnerAndRelatedAccount('aNote', $super, $accounts[0]); $socialItem = new SocialItem(); $socialItem->owner = $super; $socialItem->description = 'My test description'; $socialItem->note = $note; $socialItem->files->add($fileModel); $socialItem->toUser = $steven; $saved = $socialItem->save(); $this->assertTrue($saved); $id = $socialItem->id; $socialItem->forget(); unset($socialItem); $socialItem = SocialItem::getById($id); $this->assertEquals($super, $socialItem->owner); $this->assertEquals('My test description', $socialItem->description); $this->assertEquals($super, $socialItem->createdByUser); $this->assertEquals($note, $socialItem->note); $this->assertEquals(1, $socialItem->files->count()); $this->assertEquals($fileModel, $socialItem->files->offsetGet(0)); $this->assertEquals($steven, $socialItem->toUser); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); $super = User::getByUsername('super'); $super = User::getByUsername('super'); $super->primaryEmail = new Email(); $super->primaryEmail->emailAddress = '*****@*****.**'; assert($super->save()); // Not Coding Standard $bobby = UserTestHelper::createBasicUserWithEmailAddress('bobby'); $sarah = UserTestHelper::createBasicUserWithEmailAddress('sarah'); self::$superUserId = $super->id; self::$bobbyUserId = $bobby->id; self::$sarahUserId = $sarah->id; $file = ZurmoTestHelper::createFileModel(); $emailTemplate = new EmailTemplate(); $emailTemplate->modelClassName = 'WorkflowModelTestItem'; $emailTemplate->type = 1; $emailTemplate->name = 'some template'; $emailTemplate->subject = 'some subject [[LAST^NAME]]'; $emailTemplate->htmlContent = 'html content [[STRING]]'; $emailTemplate->textContent = 'text content [[PHONE]]'; $emailTemplate->files->add($file); $saved = $emailTemplate->save(); if (!$saved) { throw new FailedToSaveModelException(); } self::$emailTemplate = $emailTemplate; }
public function testCreateAndGetMissionById() { $super = User::getByUsername('super'); $fileModel = ZurmoTestHelper::createFileModel(); $steven = UserTestHelper::createBasicUserWithEmailAddress('steven'); $steven->setRight('MissionsModule', MissionsModule::RIGHT_ACCESS_MISSIONS); $steven->save(); $dueStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 10000); $mission = new Mission(); $mission->owner = $super; $mission->takenByUser = $steven; $mission->dueDateTime = $dueStamp; $mission->description = 'My test description'; $mission->reward = 'My test reward'; $mission->status = Mission::STATUS_AVAILABLE; $mission->files->add($fileModel); $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME); $mission->addPermissions($everyoneGroup, Permission::READ_WRITE); $this->assertTrue($mission->save()); AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($mission, $everyoneGroup); $id = $mission->id; $mission->forget(); unset($mission); $mission = Mission::getById($id); $this->assertEquals('My test description', $mission->description); $this->assertEquals('My test reward', $mission->reward); $this->assertEquals(Mission::STATUS_AVAILABLE, $mission->status); $this->assertEquals($super, $mission->owner); $this->assertEquals($steven, $mission->takenByUser); $this->assertEquals(1, $mission->files->count()); $this->assertEquals($fileModel, $mission->files->offsetGet(0)); $this->assertEquals($dueStamp, $mission->dueDateTime); $this->assertTrue(MissionsUtil::hasUserReadMissionLatest($mission, $super)); $this->assertFalse(MissionsUtil::hasUserReadMissionLatest($mission, $steven)); }
public function testRenderDownloadLinkContentByRelationModelAndFileModel() { Yii::app()->user->userModel = User::getByUsername('super'); $model = new ModelWithAttachmentTestItem(); $fileModel = ZurmoTestHelper::createFileModel(); $link = FileModelDisplayUtil::renderDownloadLinkContentByRelationModelAndFileModel($model, $fileModel); $this->assertNotNull($link); }
public function setUp() { parent::setUp(); Yii::app()->user->userModel = User::getByUsername('super'); $file = ZurmoTestHelper::createImageFileModel(); $this->imageFile1Id = $file->id; $file->forget(); }
public function testResolveBindRegisteredDomain() { Yii::app()->user->userModel = User::getByUsername('super'); if (!ZurmoTestHelper::isAuthenticationLdapTestConfigurationSet()) { $this->markTestSkipped(Zurmo::t('ZurmoModule', 'Test Ldap settings are not configured in perInstanceTest.php file.')); } //to show the fix for resolveBindRegisteredDomain with incorrect Base Domain $bindRegisteredDomain = LdapUtil::resolveBindRegisteredDomain('testUser', 'test'); $this->assertEquals('testUser', $bindRegisteredDomain); //to show the fix for resolveBindRegisteredDomain with correct Base Domain $bindRegisteredDomain = LdapUtil::resolveBindRegisteredDomain('test', 'dc=server,dc=local'); // Not Coding Standard $this->assertEquals('*****@*****.**', $bindRegisteredDomain); }
public function testCreateAndGetConversationById() { $super = User::getByUsername('super'); $fileModel = ZurmoTestHelper::createFileModel(); $accounts = Account::getByName('anAccount'); $steven = UserTestHelper::createBasicUser('steven'); $conversation = new Conversation(); $conversation->owner = $super; $conversation->subject = 'My test subject'; $conversation->description = 'My test description'; $conversation->conversationItems->add($accounts[0]); $conversation->files->add($fileModel); $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('My test subject', $conversation->subject); $this->assertEquals('My test description', $conversation->description); $this->assertEquals($super, $conversation->owner); $this->assertEquals(1, $conversation->conversationItems->count()); $this->assertEquals($accounts[0]->getClassId('Item'), $conversation->conversationItems->offsetGet(0)->id); $this->assertEquals(1, $conversation->files->count()); $this->assertEquals($fileModel, $conversation->files->offsetGet(0)); $this->assertEquals(1, $conversation->conversationParticipants->count()); $this->assertEquals($steven, $conversation->conversationParticipants->offsetGet(0)->person); $this->assertEquals(1, $conversation->ownerHasReadLatest); //Clear conversation so permissions take properly. Needed because we don't have changes between page loads. $id = $conversation->id; $conversation->forget(); unset($conversation); //At this point there should be one readWritePermitable. "Steven" $conversation = Conversation::getById($id); $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($conversation); $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables(); $this->assertEquals(1, count($readWritePermitables)); $this->assertEquals($steven, $readWritePermitables[$steven->getClassId('Permitable')]); $this->assertEquals(1, $conversation->conversationParticipants->count()); $this->assertEquals($steven, $conversation->conversationParticipants[0]->person); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); $super = User::getByUsername('super'); $super = User::getByUsername('super'); $super->primaryEmail = new Email(); $super->primaryEmail->emailAddress = '*****@*****.**'; assert($super->save()); // Not Coding Standard //Create alpha group $group = new Group(); $group->name = 'Alpha'; $saved = $group->save(); assert($saved); // Not Coding Standard self::$alphaGroup = $group; //Now set default permissions to owner and users in group Alpha $form = UserConfigurationFormAdapter::makeFormFromUserConfigurationByUser($super); $form->defaultPermissionSetting = UserConfigurationForm::DEFAULT_PERMISSIONS_SETTING_OWNER_AND_USERS_IN_GROUP; $form->defaultPermissionGroupSetting = $group->id; UserConfigurationFormAdapter::setConfigurationFromForm($form, $super); $bobby = UserTestHelper::createBasicUserWithEmailAddress('bobby'); $sarah = UserTestHelper::createBasicUserWithEmailAddress('sarah'); self::$superUserId = $super->id; self::$bobbyUserId = $bobby->id; self::$sarahUserId = $sarah->id; $file = ZurmoTestHelper::createFileModel(); $emailTemplate = new EmailTemplate(); $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_PASTED_HTML; $emailTemplate->modelClassName = 'WorkflowModelTestItem'; $emailTemplate->type = 1; $emailTemplate->name = 'some template'; $emailTemplate->subject = 'some subject [[LAST^NAME]]'; $emailTemplate->htmlContent = 'html content [[STRING]]'; $emailTemplate->textContent = 'text content [[PHONE]]'; $emailTemplate->files->add($file); $saved = $emailTemplate->save(); if (!$saved) { throw new FailedToSaveModelException(); } self::$emailTemplate = $emailTemplate; $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME); assert($everyoneGroup->save()); // Not Coding Standard }
public function testAddParicipantAndHaveParticipantRemoveSelf() { return; //Turn on once issue is fixed with SECURITY_OPTIMIZED and this bug. $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $fileModel = ZurmoTestHelper::createFileModel(); $accounts = Account::getByName('anAccount'); $steven = UserTestHelper::createBasicUser('steven'); $conversation = new Conversation(); $conversation->owner = $super; $conversation->subject = 'My test subject'; $conversation->description = 'My test description'; $this->assertTrue($conversation->save()); $sally = UserTestHelper::createBasicUser('sally'); $conversation->addPermissions($sally, Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER); $conversation->save(); //Log in as sally, and remove her permission Yii::app()->user->userModel = $sally; //Breaks because SecurableItem 2 spots using SECURITY_OPTIMIZATION == false, think it is the first spot //todo: fix. $conversation->removePermissions(Yii::app()->user->userModel, Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER, Permission::ALLOW); }
/** * @depends testRunWithContactContainingPrimaryEmailOptedOut */ public function testRunWithMultipleRecipientsWithAttachments() { $campaignItemsCountBefore = CampaignItem::getCount(); $job = new CampaignQueueMessagesInOutboxJob(); $contacts = array(); for ($i = 0; $i < 5; $i++) { $email = new Email(); $email->emailAddress = "demo{$i}@zurmo.com"; $contact = ContactTestHelper::createContactByNameForOwner('contact 0' . ($i + 8), $this->user); $contact->primaryEmail = $email; $this->assertTrue($contact->save()); $contacts[] = $contact; } $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList 09', 'description goes here', 'fromName', '*****@*****.**'); $campaign = CampaignTestHelper::createCampaign('campaign 09', 'subject', '[[FIRST^NAME]]', '[[LAST^NAME]]', null, null, null, Campaign::STATUS_PROCESSING, null, null, $marketingList); $fileNames = array('testImage.png', 'testZip.zip', 'testPDF.pdf'); $files = array(); foreach ($fileNames as $index => $fileName) { $file = ZurmoTestHelper::createFileModel($fileName); $files[$index]['name'] = $fileName; $files[$index]['type'] = $file->type; $files[$index]['size'] = $file->size; $files[$index]['contents'] = $file->fileContent->content; $campaign->files->add($file); } $this->assertTrue($campaign->save()); $processed = 0; foreach ($contacts as $contact) { MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList, $contact); CampaignItemTestHelper::createCampaignItem($processed, $campaign, $contact); } $this->assertTrue($job->run()); ForgetAllCacheUtil::forgetAllCaches(); $campaignItemsCountExpected = $campaignItemsCountBefore + 5; $campaignItemsCountAfter = CampaignItem::getCount(); $this->assertEquals($campaignItemsCountExpected, $campaignItemsCountAfter); $campaignItemsProcessed = CampaignItem::getByProcessedAndCampaignId(1, $campaign->id); $this->assertCount(5, $campaignItemsProcessed); foreach ($campaignItemsProcessed as $campaignItem) { $emailMessage = $campaignItem->emailMessage; $this->assertNotEmpty($emailMessage->files); $this->assertCount(count($files), $emailMessage->files); foreach ($files as $index => $file) { $this->assertEquals($files[$index]['name'], $emailMessage->files[$index]->name); $this->assertEquals($files[$index]['type'], $emailMessage->files[$index]->type); $this->assertEquals($files[$index]['size'], $emailMessage->files[$index]->size); $this->assertEquals($files[$index]['contents'], $emailMessage->files[$index]->fileContent->content); } } }
public function testMakeByExistingFileModelId() { Yii::app()->user->userModel = User::getByUsername('super'); $file1 = ZurmoTestHelper::createFileModel(); $file2 = FileModelUtil::makeByExistingFileModelId($file1->id); $this->assertTrue($file2 !== false); $this->assertEquals($file1->fileContent->content, $file2->fileContent->content); $this->assertEquals($file1->name, $file2->name); $this->assertEquals($file1->type, $file2->type); $this->assertEquals($file1->size, $file2->size); }
public function testCreateMultipleEmailMessageWithAttachments() { $jane = User::getByUsername('jane'); $billy = User::getByUsername('billy'); $emailMessageIds = array(); for ($count = 0; $count < 5; $count++) { $emailMessage = new EmailMessage(); $emailMessage->owner = $jane; $emailMessage->subject = 'My Email with 2 Attachments'; $emailMessage->files->add(ZurmoTestHelper::createFileModel('testNote.txt')); $emailMessage->files->add(ZurmoTestHelper::createFileModel('testPDF.pdf')); //Set sender, and recipient, and content $emailContent = new EmailMessageContent(); $emailContent->textContent = 'My Second Message'; $emailMessage->content = $emailContent; //Sending from jane $sender = new EmailMessageSender(); $sender->fromAddress = '*****@*****.**'; $sender->fromName = 'Jane Smith'; $sender->personsOrAccounts->add($jane); $emailMessage->sender = $sender; //Recipient is billy. $recipient = new EmailMessageRecipient(); $recipient->toAddress = '*****@*****.**'; $recipient->toName = 'Billy James'; $recipient->type = EmailMessageRecipient::TYPE_TO; $recipient->personsOrAccounts->add($billy); $emailMessage->recipients->add($recipient); //At this point the message is not in a folder. $this->assertTrue($emailMessage->folder->id < 0); $box = EmailBox::resolveAndGetByName('JaneBox'); $emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT); //Save, at this point the email should be in the draft folder $saved = $emailMessage->save(); $this->assertTrue($saved); $this->assertTrue($emailMessage->folder->id > 0); $emailMessageIds[] = $emailMessage->id; unset($emailMessage); ForgetAllCacheUtil::forgetAllCaches(); } foreach ($emailMessageIds as $id) { $emailMessage = EmailMessage::getById($id); $this->assertEquals('My Email with 2 Attachments', $emailMessage->subject); $this->assertEquals(2, $emailMessage->files->count()); unset($emailMessage); ForgetAllCacheUtil::forgetAllCaches(); } }
/** * @depends testSaveWithValidDataWithValidation */ public function testSaveWithFiles() { $fileNames = array('testImage.png', 'testZip.zip', 'testPDF.pdf'); $filesIds = array(); foreach ($fileNames as $index => $fileName) { $file = ZurmoTestHelper::createFileModel($fileName); $filesIds[] = $file->id; } $post = array('ClassicEmailTemplateWizardForm' => array('name' => 'plainText 03', 'subject' => 'plainText 03', 'type' => 2, 'builtType' => 1, 'isDraft' => 0, 'language' => '', 'hiddenId' => 0, 'modelClassName' => 'Contact', 'ownerId' => 1, 'ownerName' => 'Super User', 'textContent' => 'some text', 'explicitReadWriteModelPermissions' => array('nonEveryoneGroup' => 3, 'type' => 1)), 'filesIds' => $filesIds, 'validationScenario' => BuilderEmailTemplateWizardForm::PLAIN_AND_RICH_CONTENT_VALIDATION_SCENARIO, 'ajax' => 'edit-form'); $this->setGetArray(array('builtType' => EmailTemplate::BUILT_TYPE_PLAIN_TEXT_ONLY)); $this->setPostArray($post); $content = $this->runControllerWithExitExceptionAndGetContent('emailTemplates/default/save'); $jsonDecodedContent = CJSON::decode($content); $this->assertEmpty($jsonDecodedContent); // now send the actual save request unset($post['ajax']); $this->setPostArray($post); $content = $this->runControllerWithExitExceptionAndGetContent('emailTemplates/default/save'); $jsonDecodedContent = CJSON::decode($content); $this->assertNotEmpty($jsonDecodedContent); $this->assertCount(3, $jsonDecodedContent); $this->assertArrayHasKey('id', $jsonDecodedContent); $this->assertArrayHasKey('redirectToList', $jsonDecodedContent); $this->assertFalse($jsonDecodedContent['redirectToList']); $this->assertArrayHasKey('moduleClassName', $jsonDecodedContent); $this->assertEquals('ContactsModule', $jsonDecodedContent['moduleClassName']); $emailTemplate = EmailTemplate::getById((int) $jsonDecodedContent['id']); $this->assertCount(3, $emailTemplate->files); }
public function testAttachFilesToMessage() { $billy = User::getByUsername('billy'); Yii::app()->user->userModel = $billy; $filesIds = array(); $fileTxt = ZurmoTestHelper::createFileModel('testNote.txt', 'FileModel'); $filesIds[] = $fileTxt->id; $filePng = ZurmoTestHelper::createFileModel('testImage.png', 'FileModel'); $filesIds[] = $filePng->id; $fileZip = ZurmoTestHelper::createFileModel('testZip.zip', 'FileModel'); $filesIds[] = $fileZip->id; $filePdf = ZurmoTestHelper::createFileModel('testPDF.pdf', 'FileModel'); $filesIds[] = $filePdf->id; $emailMessage = new EmailMessage(); EmailMessageUtil::attachFilesToMessage($filesIds, $emailMessage); $this->assertEquals('4', count($emailMessage->files)); }
/** * @depends testProcessDueAutoresponderItemWithValidMergeTags */ public function testProcessDueAutoresponderItemWithAttachments() { $email = new Email(); $email->emailAddress = '*****@*****.**'; $contact = ContactTestHelper::createContactByNameForOwner('contact 06', $this->user); $contact->primaryEmail = $email; $this->assertTrue($contact->save()); $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList 06', 'description', 'CustomFromName', '*****@*****.**'); $autoresponder = AutoresponderTestHelper::createAutoresponder('subject 06', 'Dr. [[FIRST^NAME]] [[LAST^NAME]]', '<b>[[LAST^NAME]]</b>, [[FIRST^NAME]]', 1, Autoresponder::OPERATION_SUBSCRIBE, true, $marketingList); $fileNames = array('testImage.png', 'testZip.zip', 'testPDF.pdf'); $files = array(); foreach ($fileNames as $index => $fileName) { $file = ZurmoTestHelper::createFileModel($fileName); $files[$index]['name'] = $fileName; $files[$index]['type'] = $file->type; $files[$index]['size'] = $file->size; $files[$index]['contents'] = $file->fileContent->content; $autoresponder->files->add($file); } $this->assertTrue($autoresponder->save()); $processed = 0; $processDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time()); $autoresponderItem = AutoresponderItemTestHelper::createAutoresponderItem($processed, $processDateTime, $autoresponder, $contact); $this->processDueItem($autoresponderItem); $this->assertEquals(1, $autoresponderItem->processed); $emailMessage = $autoresponderItem->emailMessage; $this->assertEquals($marketingList->owner->id, $emailMessage->owner->id); $marketingListPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($marketingList); $emailMessagePermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($emailMessage); $this->assertEquals($marketingListPermissions, $emailMessagePermissions); $this->assertEquals($autoresponder->subject, $emailMessage->subject); $this->assertNotEquals($autoresponder->textContent, $emailMessage->content->textContent); $this->assertNotEquals($autoresponder->htmlContent, $emailMessage->content->htmlContent); $this->assertContains('Dr. contact 06 contact 06son', $emailMessage->content->textContent); $this->assertContains('/marketingLists/external/', $emailMessage->content->textContent); $this->assertEquals(2, substr_count($emailMessage->content->textContent, '/marketingLists/external/')); $this->assertContains('<b>contact 06son</b>, contact 06', $emailMessage->content->htmlContent); $this->assertContains('/marketingLists/external/', $emailMessage->content->htmlContent); $this->assertEquals(2, substr_count($emailMessage->content->htmlContent, '/marketingLists/external/')); $this->assertEquals($marketingList->fromAddress, $emailMessage->sender->fromAddress); $this->assertEquals($marketingList->fromName, $emailMessage->sender->fromName); $this->assertEquals(1, $emailMessage->recipients->count()); $recipients = $emailMessage->recipients; $this->assertEquals(strval($contact), $recipients[0]->toName); $this->assertEquals($email->emailAddress, $recipients[0]->toAddress); $this->assertEquals(EmailMessageRecipient::TYPE_TO, $recipients[0]->type); $this->assertTrue($contact->isSame($recipients[0]->personsOrAccounts[0])); $this->assertNotEmpty($emailMessage->files); $this->assertCount(count($files), $emailMessage->files); foreach ($autoresponder->files as $index => $file) { $this->assertEquals($file->name, $emailMessage->files[$index]->name); $this->assertEquals($file->type, $emailMessage->files[$index]->type); $this->assertEquals($file->size, $emailMessage->files[$index]->size); //AutoresponderItem should share the Attachments content from Autoresponder $this->assertEquals($file->fileContent->content, $emailMessage->files[$index]->fileContent->content); } $headersArray = array('zurmoItemId' => $autoresponderItem->id, 'zurmoItemClass' => get_class($autoresponderItem), 'zurmoPersonId' => $contact->getClassId('Person')); $expectedHeaders = serialize($headersArray); $this->assertEquals($expectedHeaders, $emailMessage->headers); }
public function generateCampaignItemsForDueCampaigns($count) { $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList Test', 'description goes here', 'fromName', '*****@*****.**'); $marketingListId = $marketingList->id; $contacts = array(); $emails = array(); for ($i = 0; $i < $count; $i++) { $emails[$i] = new Email(); $emails[$i]->emailAddress = "demo{$i}@zurmo.com"; $account = AccountTestHelper::createAccountByNameForOwner('account ' . $i, $this->user); $contact = ContactTestHelper::createContactWithAccountByNameForOwner('contact ' . $i, $this->user, $account); $contact->primaryEmail = $emails[$i]; $this->assertTrue($contact->save()); $contacts[$i] = $contact; MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList, $contact); } $marketingList->forgetAll(); $marketingList = MarketingList::getById($marketingListId); $content = <<<MTG [[COMPANY^NAME]] [[CREATED^DATE^TIME]] [[DEPARTMENT]] [[DESCRIPTION]] [[FIRST^NAME]] [[GOOGLE^WEB^TRACKING^ID]] [[INDUSTRY]] [[JOB^TITLE]] [[LAST^NAME]] [[LATEST^ACTIVITY^DATE^TIME]] [[MOBILE^PHONE]] [[MODIFIED^DATE^TIME]] [[OFFICE^FAX]] [[OFFICE^PHONE]] [[TITLE]] [[SOURCE]] [[STATE]] [[WEBSITE]] [[MODEL^URL]] [[BASE^URL]] [[APPLICATION^NAME]] [[CURRENT^YEAR]] [[LAST^YEAR]] [[OWNERS^AVATAR^SMALL]] [[OWNERS^AVATAR^MEDIUM]] [[OWNERS^AVATAR^LARGE]] [[OWNERS^EMAIL^SIGNATURE]] [[UNSUBSCRIBE^URL]] [[MANAGE^SUBSCRIPTIONS^URL]] [[PRIMARY^EMAIL__EMAIL^ADDRESS]] [[PRIMARY^EMAIL__EMAIL^ADDRESS]] [[SECONDARY^ADDRESS__CITY]] [[SECONDARY^ADDRESS__COUNTRY]] [[SECONDARY^ADDRESS__INVALID]] [[SECONDARY^ADDRESS__LATITUDE]] [[SECONDARY^ADDRESS__LONGITUDE]] [[SECONDARY^ADDRESS__POSTAL^CODE]] [[SECONDARY^ADDRESS__STATE]] [[SECONDARY^ADDRESS__STREET1]] [[SECONDARY^ADDRESS__STREET2]] [[OWNER__DEPARTMENT]] [[OWNER__FIRST^NAME]] [[OWNER__IS^ACTIVE]] [[OWNER__MOBILE^PHONE]] [[OWNER__LAST^LOGIN^DATE^TIME]] [[OWNER__LAST^NAME]] [[CREATED^BY^USER__FIRST^NAME]] [[CREATED^BY^USER__LAST^NAME]] [[CREATED^BY^USER__MOBILE^PHONE]] [[CREATED^BY^USER__TITLE]] [[CREATED^BY^USER__USERNAME]] [[ACCOUNT__ANNUAL^REVENUE]] [[ACCOUNT__INDUSTRY]] [[ACCOUNT__NAME]] [[ACCOUNT__WEBSITE]] [[ACCOUNT__BILLING^ADDRESS__COUNTRY]] [[ACCOUNT__BILLING^ADDRESS__CITY]] [[ACCOUNT__OWNER__FIRST^NAME]] ' " ` " ' MTG; $sendOnDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 600); $campaign = CampaignTestHelper::createCampaign('campaign Test', 'subject', $content, $content, null, null, null, Campaign::STATUS_ACTIVE, $sendOnDateTime, null, $marketingList, false); $fileNames = array('testImage.png', 'testZip.zip', 'testPDF.pdf'); $files = array(); foreach ($fileNames as $index => $fileName) { $file = ZurmoTestHelper::createFileModel($fileName); $files[$index]['name'] = $fileName; $files[$index]['type'] = $file->type; $files[$index]['size'] = $file->size; $files[$index]['contents'] = $file->fileContent->content; $campaign->files->add($file); } $this->assertTrue($campaign->save(false)); $campaignId = $campaign->id; $campaign->forgetAll(); $campaignItems = CampaignItem::getByProcessedAndCampaignId(0, $campaignId); $this->assertEmpty($campaignItems); //Process open campaigns. Yii::app()->jobQueue->deleteAll(); AutoresponderOrCampaignBatchSizeConfigUtil::setBatchSize($count); Yii::app()->jobQueue->deleteAll(); $this->assertCount(0, Yii::app()->jobQueue->getAll()); ForgetAllCacheUtil::forgetAllCaches(); $job = new CampaignGenerateDueCampaignItemsJob(); $startedAt = microtime(true); $this->assertTrue($job->run()); $timeTaken = microtime(true) - $startedAt; ForgetAllCacheUtil::forgetAllCaches(); $campaign->forgetAll(); unset($campaign); $campaign = Campaign::getById($campaignId); $this->assertNotNull($campaign); $this->assertEquals(Campaign::STATUS_PROCESSING, $campaign->status); $campaignItems = CampaignItem::getByProcessedAndCampaignId(0, $campaignId); $this->assertNotEmpty($campaignItems); $this->assertCount($count, $campaignItems); return $timeTaken; }
public function generateAndProcessEmailMessages($count) { $box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME); $outboxFolder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_OUTBOX); $sentFolder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_SENT); $fileNames = array('testImage.png', 'testZip.zip', 'testPDF.pdf'); $emailMessageIds = array(); $files = array(); for ($i = 0; $i < $count; $i++) { $emailMessage = EmailMessageTestHelper::createDraftSystemEmail('My Email Message ' . $i, $this->user); foreach ($fileNames as $index => $fileName) { $file = ZurmoTestHelper::createFileModel($fileName); $files[$index]['name'] = $fileName; $files[$index]['type'] = $file->type; $files[$index]['size'] = $file->size; $files[$index]['contents'] = $file->fileContent->content; $emailMessage->files->add($file); } $emailMessage->folder = $outboxFolder; $saved = $emailMessage->save(false); $this->assertTrue($saved); $emailMessageIds[] = $emailMessage->id; $emailMessage->forget(); unset($emailMessage); } OutboundEmailBatchSizeConfigUtil::setBatchSize($count + 1); Yii::app()->jobQueue->deleteAll(); ForgetAllCacheUtil::forgetAllCaches(); $job = new ProcessOutboundEmailJob(); $startedAt = microtime(true); $this->assertTrue($job->run()); $timeTaken = microtime(true) - $startedAt; ForgetAllCacheUtil::forgetAllCaches(); $emailMessages = EmailMessage::getAll(); $this->assertEquals($count, count($emailMessages)); foreach ($emailMessageIds as $i => $emailMessageId) { $emailMessage = EmailMessage::getById($emailMessageId); $this->assertEquals('My Email Message ' . $i, $emailMessage->subject); $this->assertEquals(1, $emailMessage->sendAttempts); $this->assertEquals($sentFolder->id, $emailMessage->folder->id); $this->assertNotEmpty($emailMessage->files); $this->assertCount(count($files), $emailMessage->files); foreach ($emailMessage->files as $index => $file) { $this->assertEquals($file->name, $emailMessage->files[$index]->name); $this->assertEquals($file->type, $emailMessage->files[$index]->type); $this->assertEquals($file->size, $emailMessage->files[$index]->size); $this->assertEquals($file->fileContent->content, $emailMessage->files[$index]->fileContent->content); $this->assertEquals($file->fileContent->id, $emailMessage->files[$index]->fileContent->id); } } return $timeTaken; }
public function generateAndProcessCampaignItems($count) { $contacts = array(); $emails = array(); for ($i = 0; $i < $count; $i++) { $emails[$i] = new Email(); $emails[$i]->emailAddress = "demo{$i}@zurmo.com"; $account = AccountTestHelper::createAccountByNameForOwner('account ' . $i, $this->user); $contact = ContactTestHelper::createContactWithAccountByNameForOwner('contact ' . $i, $this->user, $account); $contact->primaryEmail = $emails[$i]; $this->assertTrue($contact->save()); $contacts[$i] = $contact; } $content = <<<MTG [[COMPANY^NAME]] [[CREATED^DATE^TIME]] [[DEPARTMENT]] [[DESCRIPTION]] [[FIRST^NAME]] [[GOOGLE^WEB^TRACKING^ID]] [[INDUSTRY]] [[JOB^TITLE]] [[LAST^NAME]] [[LATEST^ACTIVITY^DATE^TIME]] [[MOBILE^PHONE]] [[MODIFIED^DATE^TIME]] [[OFFICE^FAX]] [[OFFICE^PHONE]] [[TITLE]] [[SOURCE]] [[STATE]] [[WEBSITE]] [[MODEL^URL]] [[BASE^URL]] [[APPLICATION^NAME]] [[CURRENT^YEAR]] [[LAST^YEAR]] [[OWNERS^AVATAR^SMALL]] [[OWNERS^AVATAR^MEDIUM]] [[OWNERS^AVATAR^LARGE]] [[OWNERS^EMAIL^SIGNATURE]] [[UNSUBSCRIBE^URL]] [[MANAGE^SUBSCRIPTIONS^URL]] [[PRIMARY^EMAIL__EMAIL^ADDRESS]] [[PRIMARY^EMAIL__EMAIL^ADDRESS]] [[SECONDARY^ADDRESS__CITY]] [[SECONDARY^ADDRESS__COUNTRY]] [[SECONDARY^ADDRESS__INVALID]] [[SECONDARY^ADDRESS__LATITUDE]] [[SECONDARY^ADDRESS__LONGITUDE]] [[SECONDARY^ADDRESS__POSTAL^CODE]] [[SECONDARY^ADDRESS__STATE]] [[SECONDARY^ADDRESS__STREET1]] [[SECONDARY^ADDRESS__STREET2]] [[OWNER__DEPARTMENT]] [[OWNER__FIRST^NAME]] [[OWNER__IS^ACTIVE]] [[OWNER__MOBILE^PHONE]] [[OWNER__LAST^LOGIN^DATE^TIME]] [[OWNER__LAST^NAME]] [[CREATED^BY^USER__FIRST^NAME]] [[CREATED^BY^USER__LAST^NAME]] [[CREATED^BY^USER__MOBILE^PHONE]] [[CREATED^BY^USER__TITLE]] [[CREATED^BY^USER__USERNAME]] [[ACCOUNT__ANNUAL^REVENUE]] [[ACCOUNT__INDUSTRY]] [[ACCOUNT__NAME]] [[ACCOUNT__WEBSITE]] [[ACCOUNT__BILLING^ADDRESS__COUNTRY]] [[ACCOUNT__BILLING^ADDRESS__CITY]] [[ACCOUNT__OWNER__FIRST^NAME]] ' " ` " ' MTG; $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList Test', 'description goes here', 'fromName', '*****@*****.**'); $campaign = CampaignTestHelper::createCampaign('campaign Test', 'subject', $content, $content, null, null, null, Campaign::STATUS_PROCESSING, null, null, $marketingList, false); $fileNames = array('testImage.png', 'testZip.zip', 'testPDF.pdf'); $files = array(); foreach ($fileNames as $index => $fileName) { $file = ZurmoTestHelper::createFileModel($fileName); $files[$index]['name'] = $fileName; $files[$index]['type'] = $file->type; $files[$index]['size'] = $file->size; $files[$index]['contents'] = $file->fileContent->content; $campaign->files->add($file); } $this->assertTrue($campaign->save(false)); $processed = 0; foreach ($contacts as $contact) { MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList, $contact); CampaignItemTestHelper::createCampaignItem($processed, $campaign, $contact); } AutoresponderOrCampaignBatchSizeConfigUtil::setBatchSize($count); Yii::app()->jobQueue->deleteAll(); ForgetAllCacheUtil::forgetAllCaches(); $job = new CampaignQueueMessagesInOutboxJob(); $this->assertCount(0, Yii::app()->jobQueue->getAll()); $startedAt = microtime(true); $this->assertTrue($job->run()); $timeTaken = microtime(true) - $startedAt; ForgetAllCacheUtil::forgetAllCaches(); $campaignItemsCountExpected = $count; $campaignItemsCountAfter = CampaignItem::getCount(); $this->assertEquals($campaignItemsCountExpected, $campaignItemsCountAfter); $campaignItemsProcessed = CampaignItem::getByProcessedAndCampaignId(1, $campaign->id); $this->assertCount($count, $campaignItemsProcessed); foreach ($campaignItemsProcessed as $i => $campaignItem) { $contact = $contacts[$i]; $email = $emails[$i]; $emailMessage = $campaignItem->emailMessage; $this->assertEquals($marketingList->owner->id, $emailMessage->owner->id); $marketingListPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($marketingList); $emailMessagePermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($emailMessage); $this->assertEquals($marketingListPermissions, $emailMessagePermissions); $this->assertEquals($campaign->subject, $emailMessage->subject); $this->assertNotEquals($campaign->textContent, $emailMessage->content->textContent); $this->assertNotEquals($campaign->htmlContent, $emailMessage->content->htmlContent); $this->assertEquals(2, substr_count($emailMessage->content->textContent, '/marketingLists/external/')); $this->assertContains('/marketingLists/external/', $emailMessage->content->htmlContent); $this->assertEquals(2, substr_count($emailMessage->content->htmlContent, '/marketingLists/external/')); $this->assertEquals('*****@*****.**', $emailMessage->sender->fromAddress); $this->assertEquals('Support Team', $emailMessage->sender->fromName); $this->assertEquals(1, $emailMessage->recipients->count()); $recipients = $emailMessage->recipients; $this->assertEquals(strval($contact), $recipients[0]->toName); $this->assertEquals($email->emailAddress, $recipients[0]->toAddress); $this->assertEquals(EmailMessageRecipient::TYPE_TO, $recipients[0]->type); $this->assertNotEmpty($emailMessage->files); $this->assertCount(count($files), $emailMessage->files); foreach ($campaign->files as $index => $file) { $this->assertEquals($file->name, $emailMessage->files[$index]->name); $this->assertEquals($file->type, $emailMessage->files[$index]->type); $this->assertEquals($file->size, $emailMessage->files[$index]->size); //CampaingItem should share the Attachments content from Campaign $this->assertEquals($file->fileContent->content, $emailMessage->files[$index]->fileContent->content); $this->assertEquals($file->fileContent->id, $emailMessage->files[$index]->fileContent->id); } $headersArray = array('zurmoItemId' => $campaignItem->id, 'zurmoItemClass' => get_class($campaignItem), 'zurmoPersonId' => $contact->getClassId('Person')); $expectedHeaders = serialize($headersArray); $this->assertEquals($expectedHeaders, $emailMessage->headers); } return $timeTaken; }
public function testMakeByExistingFileModelIdWithoutSharedContent() { $oldFileContentsCount = FileContent::getCount(); $file1 = ZurmoTestHelper::createFileModel('testNote.txt'); $file2 = FileModelUtil::makeByExistingFileModelId($file1->id, false); $this->assertTrue($file2 !== false); $this->assertEquals($file1->name, $file2->name); $this->assertEquals($file1->type, $file2->type); $this->assertEquals($file1->size, $file2->size); $this->assertEquals($file1->fileContent->content, $file2->fileContent->content); // fileContent should be replicated as we explicitly passed false to sharedContent $this->assertNotEquals($file1->fileContent->id, $file2->fileContent->id); $this->assertEquals($oldFileContentsCount + 2, FileContent::getCount()); }
/** * @depends testAutomatedOccurredOnDateTimeAndLatestDateTimeChanges */ public function testNobodyCanReadWriteDeleteAndStrValOfNoteFunctionsCorrectly() { Yii::app()->user->userModel = User::getByUsername('super'); $fileModel = ZurmoTestHelper::createFileModel(); $accounts = Account::getByName('anAccount'); //create a nobody user $nobody = UserTestHelper::createBasicUser('nobody'); //create a note whoes owner is super $occurredOnStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time()); $note = new Note(); $note->owner = User::getByUsername('super'); $note->occurredOnDateTime = $occurredOnStamp; $note->description = 'myNote'; $note->activityItems->add($accounts[0]); $note->files->add($fileModel); $this->assertTrue($note->save()); //add nobody permission to read and write the note $note->addPermissions($nobody, Permission::READ_WRITE_CHANGE_PERMISSIONS); $this->assertTrue($note->save()); //revoke the permission from the nobody user to access the note $note->removePermissions($nobody, Permission::READ_WRITE_CHANGE_PERMISSIONS); $this->assertTrue($note->save()); //add nobody permission to read, write and delete the note $note->addPermissions($nobody, Permission::READ_WRITE_DELETE); $this->assertTrue($note->save()); //now acces to the notes read by nobody should not fail Yii::app()->user->userModel = $nobody; $this->assertEquals($note->description, strval($note)); }
public function testSuperUserResolveBindRegisteredDomain() { if (!ZurmoTestHelper::isAuthenticationLdapTestConfigurationSet()) { $this->markTestSkipped(Zurmo::t('ZurmoModule', 'Test Ldap settings are not configured in perInstanceTest.php file.')); } $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super'); //check Ldap connection $this->resetGetArray(); $this->setPostArray(array('LdapConfigurationForm' => array('serverType' => Yii::app()->authenticationHelper->ldapServerType, 'host' => Yii::app()->authenticationHelper->ldapHost, 'port' => Yii::app()->authenticationHelper->ldapPort, 'bindRegisteredDomain' => Yii::app()->authenticationHelper->ldapBindRegisteredDomain, 'bindPassword' => Yii::app()->authenticationHelper->ldapBindPassword, 'baseDomain' => 'testBaseDomain', 'enabled' => Yii::app()->authenticationHelper->ldapEnabled))); $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/ldap/testConnection'); $this->assertTrue(strpos($content, "Unable to connect to Ldap server") > 0); }
/** * @depends testCreateNormalEmailMessage */ public function testCreateAndSendEmailMessageWithAttachment() { $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $billy = User::getByUsername('billy'); $jane = User::getByUsername('jane'); $emailMessage = new EmailMessage(); $emailMessage->owner = $jane; $emailMessage->subject = 'My Email with an Attachment'; $fileModel = ZurmoTestHelper::createFileModel('testNote.txt', 'FileModel'); $emailMessage->files->add($fileModel); //Attempt to save without setting required information $saved = $emailMessage->save(); $this->assertFalse($saved); $compareData = array('folder' => array('name' => array('Name cannot be blank.'), 'emailBox' => array('name' => array('Name cannot be blank.'))), 'sender' => array('fromAddress' => array('From Address cannot be blank.'))); $this->assertEquals($compareData, $emailMessage->getErrors()); //Set sender, and recipient, and content $emailContent = new EmailMessageContent(); $emailContent->textContent = 'My Second Message'; $emailMessage->content = $emailContent; //Sending from jane $sender = new EmailMessageSender(); $sender->fromAddress = '*****@*****.**'; $sender->fromName = 'Jane Smith'; $sender->personOrAccount = $jane; $emailMessage->sender = $sender; //Recipient is billy. $recipient = new EmailMessageRecipient(); $recipient->toAddress = '*****@*****.**'; $recipient->toName = 'Billy James'; $recipient->type = EmailMessageRecipient::TYPE_TO; $recipient->personOrAccount = $billy; $emailMessage->recipients->add($recipient); //At this point the message is not in a folder. $this->assertTrue($emailMessage->folder->id < 0); $box = EmailBox::resolveAndGetByName('JaneBox'); $emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT); //Save, at this point the email should be in the draft folder $saved = $emailMessage->save(); $this->assertTrue($saved); $this->assertTrue($emailMessage->folder->id > 0); $id = $emailMessage->id; unset($emailMessage); $emailMessage = EmailMessage::getById($id); $this->assertEquals('My Email with an Attachment', $emailMessage->subject); $this->assertEquals(1, $emailMessage->files->count()); $this->assertEquals($fileModel, $emailMessage->files->offsetGet(0)); }
/** * @depends testSuperUserCreateActionWithParameters */ public function testSuperUserEditAction() { $autoresponderId = self::getModelIdByModelNameAndName('Autoresponder', 'Subject 04'); $redirectUrl = 'http://www.zurmo.com/'; $this->setGetArray(array('id' => $autoresponderId, 'redirectUrl' => $redirectUrl)); $content = $this->runControllerWithNoExceptionsAndGetContent('autoresponders/default/edit'); $this->assertTrue(strpos($content, '<div class="breadcrumbs">') !== false); $this->assertTrue(strpos($content, 'marketing/default/index">Marketing</a> / <a href=') !== false); $this->assertTrue(strpos($content, 'marketingLists/default/list">Lists</a> / <a href=') !== false); $this->assertTrue(strpos($content, 'marketingLists/default/details?id=' . static::$marketingListId . '">MarketingListName</a> / <span>Subject 04</span></div>') !== false); $this->assertTrue(strpos($content, 'Subject 04') !== false); $this->assertEquals(3, substr_count($content, 'Subject 04')); $this->assertTrue(strpos($content, '<span class="ellipsis-content">Subject 04</span>') !== false); $this->assertTrue(strpos($content, '<label for="Autoresponder_operationType_value" class="required">' . 'Triggered By <span class="required">*</span></label>') !== false); $this->assertTrue(strpos($content, '<label for="Autoresponder_secondsFromOperation_value" class="required">' . 'Send After <span class="required">*</span></label>') !== false); $this->assertTrue(strpos($content, '<label for="Autoresponder_subject" class="required">Subject ' . '<span class="required">*</span></label>') !== false); $this->assertTrue(strpos($content, '<input id="ytAutoresponder_enableTracking" type="hidden" ' . 'value="0" name="Autoresponder[enableTracking]"') !== false); $this->assertTrue(strpos($content, '<select name="Autoresponder[operationType]" ' . 'id="Autoresponder_operationType_value">') !== false); $this->assertTrue(strpos($content, '<option value="1">Subscription to list</option>') !== false); $this->assertTrue(strpos($content, '<option value="2" selected="selected">Unsubscribed from list</option>') !== false); $this->assertTrue(strpos($content, '<select name="Autoresponder[secondsFromOperation]" ' . 'id="Autoresponder_secondsFromOperation_value">') !== false); $this->assertTrue(strpos($content, '<option value="3600">1 Hour</option>') !== false); $this->assertTrue(strpos($content, '<option value="14400" selected="selected">4 Hours</option>') !== false); $this->assertTrue(strpos($content, '<option value="28800">8 Hours</option>') !== false); $this->assertTrue(strpos($content, '<option value="43200">12 Hours</option>') !== false); $this->assertTrue(strpos($content, '<option value="86400">1 day</option>') !== false); $this->assertTrue(strpos($content, '<option value="259200">3 days</option>') !== false); $this->assertTrue(strpos($content, '<option value="345600">4 days</option>') !== false); $this->assertTrue(strpos($content, '<option value="432000">5 days</option>') !== false); $this->assertTrue(strpos($content, '<option value="864000">10 days</option>') !== false); $this->assertTrue(strpos($content, '<option value="604800">1 week</option>') !== false); $this->assertTrue(strpos($content, '<option value="1209600">2 weeks</option>') !== false); $this->assertTrue(strpos($content, '<option value="1814400">3 weeks</option>') !== false); $this->assertTrue(strpos($content, '<option value="2592000">1 month</option>') !== false); $this->assertTrue(strpos($content, '<option value="5184000">2 months</option>') !== false); $this->assertTrue(strpos($content, '<option value="7776000">3 months</option>') !== false); $this->assertTrue(strpos($content, '<option value="10368000">4 months</option>') !== false); $this->assertTrue(strpos($content, '<option value="12960000">5 months</option>') !== false); $this->assertTrue(strpos($content, '<option value="15552000">6 months</option>') !== false); $this->assertTrue(strpos($content, '<option value="31104000">1 year</option>') !== false); $this->assertTrue(strpos($content, '<input id="Autoresponder_subject" name="Autoresponder[subject]" ' . 'type="text" maxlength="64" value="Subject 04"') !== false); $this->assertTrue(strpos($content, '<select name="Autoresponder[contactEmailTemplateNames]" ' . 'id="Autoresponder_contactEmailTemplateNames_value">') !== false); $this->assertTrue(strpos($content, '<option value="">Select a template</option>') !== false); $this->assertTrue(strpos($content, '>EmailTemplate 01</option>') !== false); $this->assertTrue(strpos($content, '>EmailTemplate 02</option>') !== false); $this->assertTrue(strpos($content, '>EmailTemplate 03</option>') !== false); $this->assertTrue(strpos($content, '>EmailTemplate 04</option>') !== false); $this->assertTrue(strpos($content, '<a class="active-tab" href="#tab1">Text Content</a>') !== false); $this->assertTrue(strpos($content, '<a href="#tab2">Html Content</a>') !== false); $this->assertTrue(strpos($content, '<a id="mergetag-guide" class="simple-link" ' . 'href="#">MergeTag Guide</a>') !== false); $this->assertTrue(strpos($content, '<textarea id="Autoresponder_textContent" ' . 'name="Autoresponder[textContent]" rows="6" cols="50"') !== false); $this->assertTrue(strpos($content, "<textarea id='Autoresponder_htmlContent' " . "name='Autoresponder[htmlContent]'") !== false); $this->assertTrue(strpos($content, '<label>Attachments</label>') !== false); $this->assertTrue(strpos($content, '<strong class="add-label">Add Files</strong>') !== false); $this->assertTrue(strpos($content, '<input id="Autoresponder_files" type="file" ' . 'name="Autoresponder_files"') !== false); $this->assertTrue(strpos($content, '<span class="z-label">Cancel</span>') !== false); $this->assertTrue(strpos($content, '<span class="z-label">Save</span>') !== false); $this->assertTrue(strpos($content, '<span class="z-label">Delete</span>') !== false); // modify everything: $this->setPostArray(array('Autoresponder' => array('operationType' => 1, 'secondsFromOperation' => 60 * 60 * 24, 'subject' => 'Subject 040', 'enableTracking' => 1, 'contactEmailTemplateNames' => '', 'textContent' => 'Text Content 040', 'htmlContent' => 'Html Content 040'))); $resolvedRedirectUrl = $this->runControllerWithRedirectExceptionAndGetUrl('autoresponders/default/edit'); $autoresponders = Autoresponder::getByName('Subject 040'); $this->assertEquals(1, count($autoresponders)); $this->assertTrue($autoresponders[0]->id > 0); $this->assertEquals(1, $autoresponders[0]->operationType); $this->assertEquals(60 * 60 * 24, $autoresponders[0]->secondsFromOperation); $this->assertEquals('Subject 040', $autoresponders[0]->subject); $this->assertEquals(1, $autoresponders[0]->enableTracking); $this->assertEquals('Text Content 040', $autoresponders[0]->textContent); $this->assertEquals('Html Content 040', $autoresponders[0]->htmlContent); $this->assertEquals($redirectUrl, $resolvedRedirectUrl); $autoresponders = Autoresponder::getAll(); $this->assertEquals(3, count($autoresponders)); // Now test same with file attachment $fileNames = array('testImage.png', 'testZip.zip', 'testPDF.pdf'); $files = array(); $filesIds = array(); foreach ($fileNames as $index => $fileName) { $file = ZurmoTestHelper::createFileModel($fileName); $files[$index]['name'] = $fileName; $files[$index]['type'] = $file->type; $files[$index]['size'] = $file->size; $files[$index]['contents'] = $file->fileContent->content; $filesIds[] = $file->id; } $this->setPostArray(array('Autoresponder' => array('operationType' => 1, 'secondsFromOperation' => 60 * 60 * 24, 'subject' => 'Subject 040', 'enableTracking' => 1, 'contactEmailTemplateNames' => '', 'textContent' => 'Text Content 040', 'htmlContent' => 'Html Content 040'), 'filesIds' => $filesIds)); $resolvedRedirectUrl = $this->runControllerWithRedirectExceptionAndGetUrl('autoresponders/default/edit'); $autoresponders = Autoresponder::getByName('Subject 040'); $this->assertEquals(1, count($autoresponders)); $this->assertTrue($autoresponders[0]->id > 0); $this->assertEquals(1, $autoresponders[0]->operationType); $this->assertEquals(60 * 60 * 24, $autoresponders[0]->secondsFromOperation); $this->assertEquals('Subject 040', $autoresponders[0]->subject); $this->assertEquals(1, $autoresponders[0]->enableTracking); $this->assertEquals('Text Content 040', $autoresponders[0]->textContent); $this->assertEquals('Html Content 040', $autoresponders[0]->htmlContent); $this->assertEquals($redirectUrl, $resolvedRedirectUrl); $this->assertNotEmpty($autoresponders[0]->files); $this->assertCount(count($files), $autoresponders[0]->files); foreach ($files as $index => $file) { $this->assertEquals($files[$index]['name'], $autoresponders[0]->files[$index]->name); $this->assertEquals($files[$index]['type'], $autoresponders[0]->files[$index]->type); $this->assertEquals($files[$index]['size'], $autoresponders[0]->files[$index]->size); $this->assertEquals($files[$index]['contents'], $autoresponders[0]->files[$index]->fileContent->content); } $autoresponders = Autoresponder::getAll(); $this->assertEquals(3, count($autoresponders)); }
/** * @depends testSend */ public function testSendRealEmail() { self::loadEmailHelperWithTestCredentials(); $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount()); if (EmailMessageTestHelper::isSetEmailAccountsTestConfiguration()) { $user = User::getByUsername('steve'); $user->primaryEmail->emailAddress = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapUsername']; $this->assertTrue($user->save()); Yii::app()->imap->connect(); Yii::app()->imap->deleteMessages(true); $imapStats = Yii::app()->imap->getMessageBoxStatsDetailed(); $this->assertEquals(0, $imapStats->Nmsgs); $emailMessage = EmailMessageTestHelper::createOutboxEmail($this->user, 'Test email', 'Raw content', ',b>html content</b>end.', 'Zurmo', Yii::app()->emailHelper->outboundUsername, 'Ivica', Yii::app()->params['emailTestAccounts']['userImapSettings']['imapUsername']); $filesIds = array(); $fileTxt = ZurmoTestHelper::createFileModel('testNote.txt'); $filesIds[] = $fileTxt->id; $filePng = ZurmoTestHelper::createFileModel('testImage.png'); $filesIds[] = $filePng->id; $fileZip = ZurmoTestHelper::createFileModel('testZip.zip'); $filesIds[] = $fileZip->id; $filePdf = ZurmoTestHelper::createFileModel('testPDF.pdf'); $filesIds[] = $filePdf->id; EmailMessageUtil::attachFilesToMessage($filesIds, $emailMessage); $this->assertEquals('4', count($emailMessage->files)); Yii::app()->imap->connect(); $imapStats = Yii::app()->imap->getMessageBoxStatsDetailed(); $this->assertEquals(0, $imapStats->Nmsgs); $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount()); $this->assertEquals(6, Yii::app()->emailHelper->getSentCount()); Yii::app()->emailHelper->sendQueued(); $job = new ProcessOutboundEmailJob(); $this->assertTrue($job->run()); $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount()); $this->assertEquals(7, Yii::app()->emailHelper->getSentCount()); sleep(30); Yii::app()->imap->connect(); $imapStats = Yii::app()->imap->getMessageBoxStatsDetailed(); $this->assertEquals(1, $imapStats->Nmsgs); } }
/** * @depends testSuperUserCreateActionWithParameters */ public function testSuperUserEditAction() { $autoresponderId = self::getModelIdByModelNameAndName('Autoresponder', 'Subject 04'); $redirectUrl = 'http://www.zurmo.com/'; $this->setGetArray(array('id' => $autoresponderId, 'redirectUrl' => $redirectUrl)); $content = $this->runControllerWithNoExceptionsAndGetContent('autoresponders/default/edit'); $this->assertContains('<div class="breadcrumbs">', $content); $this->assertContains('marketing/default/index">Marketing</a> / <a href=', $content); $this->assertContains('marketingLists/default/list">Lists</a> / <a href=', $content); $this->assertContains('marketingLists/default/details?id=' . static::$marketingListId . '">MarketingListName</a> / <span>Subject 04</span></div>', $content); $this->assertContains('Subject 04', $content); $this->assertEquals(3, substr_count($content, 'Subject 04')); $this->assertContains('<span class="ellipsis-content">Subject 04</span>', $content); $this->assertContains('<label for="Autoresponder_operationType_value" class="required">' . 'Triggered By <span class="required">*</span></label>', $content); $this->assertContains('<label for="Autoresponder_fromOperationDurationInterval" class="required">' . 'Send After <span class="required">*</span></label>', $content); $this->assertContains('<label for="Autoresponder_subject" class="required">Subject ' . '<span class="required">*</span></label>', $content); $this->assertContains('<input id="ytAutoresponder_enableTracking" type="hidden" ' . 'value="0" name="Autoresponder[enableTracking]"', $content); $this->assertContains('<select name="Autoresponder[operationType]" ' . 'id="Autoresponder_operationType_value">', $content); $this->assertContains('<option value="1">Subscription to list</option>', $content); $this->assertContains('<option value="2" selected="selected">Unsubscribed from list</option>', $content); $this->assertContains('<input id="Autoresponder_subject" name="Autoresponder[subject]" ' . 'type="text" maxlength="255" value="Subject 04"', $content); $this->assertContains('<tr><th><label for="Autoresponder_contactEmailTemplateNames_name">Select a template</label></th>', $content); $this->assertContains('<td colspan="1"><div class="has-model-select"><input name=""' . ' id="Autoresponder_contactEmailTemplateNames_id"' . ' value="" type="hidden" />', $content); $this->assertContains('<div class="has-model-select">', $content); $this->assertContains('<input onblur="clearIdFromAutoCompleteField($(this).val(), '' . 'Autoresponder_contactEmailTemplateNames_id');" id="Autoresponder_contact' . 'EmailTemplateNames_name" type="text" value="" ' . 'name="" />', $content); $this->assertContains('<a id="Autoresponder_contactEmailTemplateNames_SelectLink" href="#">' . '<span class="model-select-icon"></span><span class="z-spinner">' . '</span></a></div></td></tr>', $content); $this->assertContains('<a href="#tab1">Text Content</a>', $content); $this->assertContains('<a class="active-tab" href="#tab2">Html Content</a>', $content); $this->assertContains('class="simple-link" ' . 'href="#">MergeTag Guide</a>', $content); $this->assertContains('<textarea id="Autoresponder_textContent" ' . 'name="Autoresponder[textContent]" rows="6" cols="50"', $content); $this->assertContains('<textarea id="Autoresponder_htmlContent" ' . 'name="Autoresponder[htmlContent]"', $content); $this->assertContains('<label>Attachments</label>', $content); $this->assertContains('<strong class="add-label">Add Files</strong>', $content); $this->assertContains('<input id="Autoresponder_files" multiple="multiple" type="file" ' . 'name="Autoresponder_files"', $content); $this->assertContains('<span class="z-label">Cancel</span>', $content); $this->assertContains('<span class="z-label">Save</span>', $content); $this->assertContains('<span class="z-label">Delete</span>', $content); // modify everything: $this->setPostArray(array('Autoresponder' => array('operationType' => 1, 'fromOperationDurationInterval' => 60 * 60 * 24, 'fromOperationDurationType' => TimeDurationUtil::DURATION_TYPE_DAY, 'subject' => 'Subject 040', 'enableTracking' => 1, 'contactEmailTemplateNames' => '', 'textContent' => 'Text Content 040', 'htmlContent' => 'Html Content 040'))); $resolvedRedirectUrl = $this->runControllerWithRedirectExceptionAndGetUrl('autoresponders/default/edit'); $autoresponders = Autoresponder::getByName('Subject 040'); $this->assertEquals(1, count($autoresponders)); $this->assertTrue($autoresponders[0]->id > 0); $this->assertEquals(1, $autoresponders[0]->operationType); $this->assertEquals(60 * 60 * 24, $autoresponders[0]->fromOperationDurationInterval); $this->assertEquals(TimeDurationUtil::DURATION_TYPE_DAY, $autoresponders[0]->fromOperationDurationType); $this->assertEquals('Subject 040', $autoresponders[0]->subject); $this->assertEquals(1, $autoresponders[0]->enableTracking); $this->assertEquals('Text Content 040', $autoresponders[0]->textContent); $this->assertEquals('Html Content 040', $autoresponders[0]->htmlContent); $this->assertEquals($redirectUrl, $resolvedRedirectUrl); $autoresponders = Autoresponder::getAll(); $this->assertEquals(3, count($autoresponders)); // Now test same with file attachment $fileNames = array('testImage.png', 'testZip.zip', 'testPDF.pdf'); $files = array(); $filesIds = array(); foreach ($fileNames as $index => $fileName) { $file = ZurmoTestHelper::createFileModel($fileName); $files[$index]['name'] = $fileName; $files[$index]['type'] = $file->type; $files[$index]['size'] = $file->size; $files[$index]['contents'] = $file->fileContent->content; $filesIds[] = $file->id; } $this->setPostArray(array('Autoresponder' => array('operationType' => 1, 'fromOperationDurationInterval' => 60 * 60 * 24, 'fromOperationDurationType' => TimeDurationUtil::DURATION_TYPE_DAY, 'subject' => 'Subject 040', 'enableTracking' => 1, 'contactEmailTemplateNames' => '', 'textContent' => 'Text Content 040', 'htmlContent' => 'Html Content 040'), 'filesIds' => $filesIds)); $resolvedRedirectUrl = $this->runControllerWithRedirectExceptionAndGetUrl('autoresponders/default/edit'); $autoresponders = Autoresponder::getByName('Subject 040'); $this->assertEquals(1, count($autoresponders)); $this->assertTrue($autoresponders[0]->id > 0); $this->assertEquals(1, $autoresponders[0]->operationType); $this->assertEquals(60 * 60 * 24, $autoresponders[0]->fromOperationDurationInterval); $this->assertEquals(TimeDurationUtil::DURATION_TYPE_DAY, $autoresponders[0]->fromOperationDurationType); $this->assertEquals('Subject 040', $autoresponders[0]->subject); $this->assertEquals(1, $autoresponders[0]->enableTracking); $this->assertEquals('Text Content 040', $autoresponders[0]->textContent); $this->assertEquals('Html Content 040', $autoresponders[0]->htmlContent); $this->assertEquals($redirectUrl, $resolvedRedirectUrl); $this->assertNotEmpty($autoresponders[0]->files); $this->assertCount(count($files), $autoresponders[0]->files); foreach ($files as $index => $file) { $this->assertEquals($files[$index]['name'], $autoresponders[0]->files[$index]->name); $this->assertEquals($files[$index]['type'], $autoresponders[0]->files[$index]->type); $this->assertEquals($files[$index]['size'], $autoresponders[0]->files[$index]->size); $this->assertEquals($files[$index]['contents'], $autoresponders[0]->files[$index]->fileContent->content); } $autoresponders = Autoresponder::getAll(); $this->assertEquals(3, count($autoresponders)); }
/** * @depends testProcessDueCampaignItemWithValidMergeTags */ public function testProcessDueCampaignItemWithAttachments() { $email = new Email(); $email->emailAddress = '*****@*****.**'; $contact = ContactTestHelper::createContactByNameForOwner('contact 06', $this->user); $contact->primaryEmail = $email; $this->assertTrue($contact->save()); $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList 06', 'description', 'CustomFromName', '*****@*****.**'); $campaign = CampaignTestHelper::createCampaign('campaign 06', 'subject 06', 'Dr. [[FIRST^NAME]] [[LAST^NAME]]', '<b>[[LAST^NAME]]</b>, [[FIRST^NAME]]', null, null, null, null, null, null, $marketingList); $fileNames = array('testImage.png', 'testZip.zip', 'testPDF.pdf'); $files = array(); foreach ($fileNames as $index => $fileName) { $file = ZurmoTestHelper::createFileModel($fileName); $files[$index]['name'] = $fileName; $files[$index]['type'] = $file->type; $files[$index]['size'] = $file->size; $files[$index]['contents'] = $file->fileContent->content; $campaign->files->add($file); } $this->assertTrue($campaign->save()); $processed = 0; $campaignItem = CampaignItemTestHelper::createCampaignItem($processed, $campaign, $contact); CampaignItemsUtil::processDueItem($campaignItem); $this->assertEquals(1, $campaignItem->processed); $emailMessage = $campaignItem->emailMessage; $this->assertEquals($marketingList->owner, $emailMessage->owner); $marketingListPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($marketingList); $emailMessagePermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($emailMessage); $this->assertEquals($marketingListPermissions, $emailMessagePermissions); $this->assertEquals($campaign->subject, $emailMessage->subject); $this->assertNotEquals($campaign->textContent, $emailMessage->content->textContent); $this->assertNotEquals($campaign->htmlContent, $emailMessage->content->htmlContent); $this->assertTrue(strpos($emailMessage->content->textContent, 'Dr. contact 06 contact 06son') !== false); $this->assertTrue(strpos($emailMessage->content->textContent, '/marketingLists/external/') !== false); $this->assertEquals(2, substr_count($emailMessage->content->textContent, '/marketingLists/external/')); $this->assertTrue(strpos($emailMessage->content->htmlContent, '<b>contact 06son</b>, contact 06') !== false); $this->assertTrue(strpos($emailMessage->content->htmlContent, '/marketingLists/external/') !== false); $this->assertEquals(2, substr_count($emailMessage->content->htmlContent, '/marketingLists/external/')); $this->assertEquals('*****@*****.**', $emailMessage->sender->fromAddress); $this->assertEquals('Support Team', $emailMessage->sender->fromName); $this->assertEquals(1, $emailMessage->recipients->count()); $recipients = $emailMessage->recipients; $this->assertEquals(strval($contact), $recipients[0]->toName); $this->assertEquals($email->emailAddress, $recipients[0]->toAddress); $this->assertEquals(EmailMessageRecipient::TYPE_TO, $recipients[0]->type); $this->assertEquals($contact, $recipients[0]->personOrAccount); $this->assertNotEmpty($emailMessage->files); $this->assertCount(count($files), $emailMessage->files); foreach ($files as $index => $file) { $this->assertEquals($files[$index]['name'], $emailMessage->files[$index]->name); $this->assertEquals($files[$index]['type'], $emailMessage->files[$index]->type); $this->assertEquals($files[$index]['size'], $emailMessage->files[$index]->size); $this->assertEquals($files[$index]['contents'], $emailMessage->files[$index]->fileContent->content); } $headersArray = array('zurmoItemId' => $campaignItem->id, 'zurmoItemClass' => get_class($campaignItem), 'zurmoPersonId' => $contact->getClassId('Person')); $expectedHeaders = serialize($headersArray); $this->assertEquals($expectedHeaders, $emailMessage->headers); }
/** * @depends testSuperUserCreateActionForMarketing */ public function testSuperUserEditActionForMarketing() { $emailTemplateId = self::getModelIdByModelNameAndName('EmailTemplate', 'New Test EmailTemplate'); $emailTemplate = EmailTemplate::getById($emailTemplateId); $this->setGetArray(array('id' => $emailTemplateId)); $content = $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/edit'); $this->assertTrue(strpos($content, '<span class="ellipsis-content">' . $emailTemplate->name . '</span>') !== false); $this->assertTrue(strpos($content, '<input id="EmailTemplate_name" name="EmailTemplate[name]"' . ' type="text" maxlength="64" value="' . $emailTemplate->name . '" />') !== false); $this->assertTrue(strpos($content, '<input id="EmailTemplate_subject" name="EmailTemplate[subject]"' . ' type="text" maxlength="64" value="' . $emailTemplate->subject . '" />') !== false); $this->assertTrue(strpos($content, '<textarea id="EmailTemplate_textContent" name="EmailTemplate[textContent]"' . ' rows="6" cols="50">' . $emailTemplate->textContent . '</textarea>') !== false); $this->assertTrue(strpos($content, '<textarea id=\'EmailTemplate_htmlContent\' name=\'EmailTemplate[htmlContent]\'>' . $emailTemplate->htmlContent . '</textarea>') !== false); // Test having a failed validation on the emailTemplate during save. $this->setGetArray(array('id' => $emailTemplateId)); $this->setPostArray(array('EmailTemplate' => array('name' => '', 'htmlContent' => '', 'textContent' => ''))); $content = $this->runControllerWithNoExceptionsAndGetContent('emailTemplates/default/edit'); $this->assertTrue(strpos($content, 'Name cannot be blank') !== false); $this->assertTrue(strpos($content, 'Please provide at least one of the contents field.') !== false); // Send a valid post and verify saved data. $this->setPostArray(array('EmailTemplate' => array('name' => 'New Test Email Template 00', 'subject' => 'New Subject 00', 'type' => EmailTemplate::TYPE_CONTACT, 'htmlContent' => 'New HTML Content 00', 'textContent' => 'New Text Content 00'))); $this->runControllerWithRedirectExceptionAndGetUrl('emailTemplates/default/edit'); $emailTemplate = EmailTemplate::getById($emailTemplateId); $this->assertEquals('New Subject 00', $emailTemplate->subject); $this->assertEquals('New Test Email Template 00', $emailTemplate->name); $this->assertEquals(EmailTemplate::TYPE_CONTACT, $emailTemplate->type); $this->assertEquals('New Text Content 00', $emailTemplate->textContent); $this->assertEquals('New HTML Content 00', $emailTemplate->htmlContent); // Now test same with file attachment $fileNames = array('testImage.png', 'testZip.zip', 'testPDF.pdf'); $files = array(); $filesIds = array(); foreach ($fileNames as $index => $fileName) { $file = ZurmoTestHelper::createFileModel($fileName); $files[$index]['name'] = $fileName; $files[$index]['type'] = $file->type; $files[$index]['size'] = $file->size; $files[$index]['contents'] = $file->fileContent->content; $filesIds[] = $file->id; } $this->setPostArray(array('EmailTemplate' => array('name' => 'New Test Email Template 00', 'subject' => 'New Subject 00', 'type' => EmailTemplate::TYPE_CONTACT, 'htmlContent' => 'New HTML Content 00', 'textContent' => 'New Text Content 00'), 'filesIds' => $filesIds)); $this->runControllerWithRedirectExceptionAndGetUrl('emailTemplates/default/edit'); $emailTemplate = EmailTemplate::getById($emailTemplateId); $this->assertEquals('New Subject 00', $emailTemplate->subject); $this->assertEquals('New Test Email Template 00', $emailTemplate->name); $this->assertEquals(EmailTemplate::TYPE_CONTACT, $emailTemplate->type); $this->assertEquals('New Text Content 00', $emailTemplate->textContent); $this->assertEquals('New HTML Content 00', $emailTemplate->htmlContent); $this->assertNotEmpty($emailTemplate->files); $this->assertCount(count($files), $emailTemplate->files); foreach ($files as $index => $file) { $this->assertEquals($files[$index]['name'], $emailTemplate->files[$index]->name); $this->assertEquals($files[$index]['type'], $emailTemplate->files[$index]->type); $this->assertEquals($files[$index]['size'], $emailTemplate->files[$index]->size); $this->assertEquals($files[$index]['contents'], $emailTemplate->files[$index]->fileContent->content); } }
/** * @depends testCreateAndGetAutoresponderById */ public function testDeleteAutoresponder() { $autoresponders = Autoresponder::getAll(); $this->assertCount(7, $autoresponders); $autoresponderId = $autoresponders[0]->id; $processDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time()); $contact = ContactTestHelper::createContactByNameForOwner('autoresponderContact', Yii::app()->user->userModel); $saved = AutoresponderItem::addNewItem(0, $processDateTime, $contact, $autoresponders[0]); $this->assertTrue($saved); $autoresponderItems = AutoresponderItem::getByProcessedAndAutoresponderId(0, $autoresponderId); $this->assertNotEmpty($autoresponderItems); $this->assertCount(1, $autoresponderItems); $fileNames = array('testImage.png', 'testZip.zip', 'testPDF.pdf'); $files = array(); foreach ($fileNames as $index => $fileName) { $file = ZurmoTestHelper::createFileModel($fileName); $files[$index]['name'] = $fileName; $files[$index]['type'] = $file->type; $files[$index]['size'] = $file->size; $files[$index]['contents'] = $file->fileContent->content; $autoresponders[0]->files->add($file); } $this->assertTrue($autoresponders[0]->save()); $autoresponders = Autoresponder::getAll(); $this->assertNotEmpty($autoresponders[0]->files); $this->assertCount(count($files), $autoresponders[0]->files); $this->assertEquals(count($files), FileModel::getCount()); $autoresponders[0]->delete(); $autoresponders = Autoresponder::getAll(); $this->assertEquals(6, count($autoresponders)); $autoresponderitems = AutoresponderItem::getByProcessedAndAutoresponderId(0, $autoresponderId); $this->assertEquals(0, count($autoresponderitems)); $this->assertEquals(0, FileModel::getCount()); }
/** * Test case when same user exists in ldap server and in Zurmo users */ public function testUserExitsInldapAndZurmo() { if (!ZurmoTestHelper::isAuthenticationLdapTestConfigurationSet()) { $this->markTestSkipped(Zurmo::t('Default', 'Test Ldap settings are not configured in perInstanceTest.php file.')); } Yii::app()->user->userModel = User::getByUsername('super'); $username = Yii::app()->authenticationHelper->ldapBindRegisteredDomain; $password = Yii::app()->authenticationHelper->ldapBindPassword; $identity = new UserLdapIdentity($username, $password); $authenticated = $identity->authenticate(true); $this->assertEquals(0, $identity->errorCode); $this->assertTrue($authenticated); }