public function testMakeFormAndSetConfigurationFromForm()
 {
     $form = ZurmoSystemConfigurationFormAdapter::makeFormFromSystemConfiguration();
     $this->assertEquals(AutoresponderOrCampaignBatchSizeConfigUtil::CONFIG_DEFAULT_VALUE, $form->autoresponderOrCampaignBatchSize);
     $this->assertEquals(AutoresponderOrCampaignBatchSizeConfigUtil::getBatchSize(), $form->autoresponderOrCampaignBatchSize);
     $this->assertEquals(OutboundEmailBatchSizeConfigUtil::getBatchSize(), $form->outboundEmailBatchSize);
     $this->assertEquals(ZurmoSystemConfigurationUtil::getBatchSize(), $form->listPageSizeMaxLimit);
     //User is not root so he cant change batch size
     $form->autoresponderOrCampaignBatchSize = 20;
     $form->outboundEmailBatchSize = 30;
     $form->listPageSizeMaxLimit = 10;
     ZurmoSystemConfigurationFormAdapter::setConfigurationFromForm($form);
     $form = ZurmoSystemConfigurationFormAdapter::makeFormFromSystemConfiguration();
     $this->assertEquals(AutoresponderOrCampaignBatchSizeConfigUtil::CONFIG_DEFAULT_VALUE, $form->autoresponderOrCampaignBatchSize);
     $this->assertEquals(OutboundEmailBatchSizeConfigUtil::getBatchSize(), $form->outboundEmailBatchSize);
     $this->assertEquals(ZurmoSystemConfigurationUtil::getBatchSize(), $form->listPageSizeMaxLimit);
     //User is root so he can change batch size
     $super = User::getByUsername('super');
     $super->setIsRootUser();
     Yii::app()->user->userModel = $super;
     $form->autoresponderOrCampaignBatchSize = 20;
     $form->outboundEmailBatchSize = 30;
     $form->listPageSizeMaxLimit = 10;
     ZurmoSystemConfigurationFormAdapter::setConfigurationFromForm($form);
     $form = ZurmoSystemConfigurationFormAdapter::makeFormFromSystemConfiguration();
     $this->assertEquals(20, $form->autoresponderOrCampaignBatchSize);
     $this->assertEquals(30, $form->outboundEmailBatchSize);
     $this->assertEquals(10, $form->listPageSizeMaxLimit);
 }
 /**
  * Creates a form populated with the system configuration global stored values.
  * @return ZurmoSystemConfigurationForm
  */
 public static function makeFormFromSystemConfiguration()
 {
     $form = new ZurmoSystemConfigurationForm();
     $form->autoresponderOrCampaignBatchSize = AutoresponderOrCampaignBatchSizeConfigUtil::getBatchSize();
     $form->outboundEmailBatchSize = OutboundEmailBatchSizeConfigUtil::getBatchSize();
     $form->listPageSizeMaxLimit = ZurmoSystemConfigurationUtil::getBatchSize();
     return $form;
 }
 /**
  * @depends testGetBatchSizeReturnsNullFirstAndDefaultWithSetOnMissing
  */
 public function testSetBatchSize()
 {
     $size = AutoresponderOrCampaignBatchSizeConfigUtil::getBatchSize(false, false);
     $this->assertNotNull($size);
     $this->assertEquals(AutoresponderOrCampaignBatchSizeConfigUtil::CONFIG_DEFAULT_VALUE, $size);
     AutoresponderOrCampaignBatchSizeConfigUtil::setBatchSize(7);
     $size = AutoresponderOrCampaignBatchSizeConfigUtil::getBatchSize(false, false);
     $this->assertNotNull($size);
     $this->assertEquals(7, $size);
 }
 /**
  * @return ZurmoConfigurationForm
  */
 public static function makeFormFromGlobalConfiguration()
 {
     $form = new ZurmoConfigurationForm();
     $form->applicationName = ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'applicationName');
     $form->timeZone = Yii::app()->timeZoneHelper->getGlobalValue();
     $form->listPageSize = Yii::app()->pagination->getGlobalValueByType('listPageSize');
     $form->subListPageSize = Yii::app()->pagination->getGlobalValueByType('subListPageSize');
     $form->modalListPageSize = Yii::app()->pagination->getGlobalValueByType('modalListPageSize');
     $form->dashboardListPageSize = Yii::app()->pagination->getGlobalValueByType('dashboardListPageSize');
     $form->gamificationModalNotificationsEnabled = Yii::app()->gameHelper->modalNotificationsEnabled;
     $form->realtimeUpdatesEnabled = static::getRealtimeUpdatesEnabled();
     $form->autoresponderOrCampaignBatchSize = AutoresponderOrCampaignBatchSizeConfigUtil::getBatchSize();
     $form->autoresponderOrCampaignFooterPlainText = UnsubscribeAndManageSubscriptionsPlaceholderUtil::getContentByType(false);
     $form->autoresponderOrCampaignFooterRichText = UnsubscribeAndManageSubscriptionsPlaceholderUtil::getContentByType(true);
     self::getLogoAttributes($form);
     return $form;
 }
 protected function resolveBatchSize()
 {
     return AutoresponderOrCampaignBatchSizeConfigUtil::getBatchSize();
 }
예제 #6
0
 /**
  * @depends testGenerateCampaignItemsForDueCampaigns
  */
 public function testGenerateCampaignItemsForDueCampaignsWithCustomBatchSize()
 {
     $contactIds = array();
     $marketingListIds = array();
     $campaignIds = array();
     for ($index = 6; $index < 9; $index++) {
         $contact = ContactTestHelper::createContactByNameForOwner('campaignContact 0' . $index, $this->user);
         $contactIds[] = $contact->id;
         $contact->forgetAll();
     }
     for ($index = 8; $index < 12; $index++) {
         $suffix = $index;
         if ($index < 10) {
             $suffix = "0{$suffix}";
         }
         $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList ' . $suffix);
         $marketingListId = $marketingList->id;
         $marketingListIds[] = $marketingListId;
         foreach ($contactIds as $contactId) {
             $contact = Contact::getById($contactId);
             $unsubscribed = rand(10, 20) % 2;
             MarketingListMemberTestHelper::createMarketingListMember($unsubscribed, $marketingList, $contact);
         }
         $marketingList->forgetAll();
         $marketingList = MarketingList::getById($marketingListId);
         $campaignSuffix = substr($marketingList->name, -2);
         $campaign = CampaignTestHelper::createCampaign('campaign ' . $campaignSuffix, 'subject ' . $campaignSuffix, 'text ' . $campaignSuffix, 'html ' . $campaignSuffix, null, null, null, null, null, null, $marketingList);
         $this->assertNotNull($campaign);
         $campaignIds[] = $campaign->id;
         $campaign->forgetAll();
     }
     foreach ($campaignIds as $campaignId) {
         $campaignItems = CampaignItem::getByProcessedAndCampaignId(0, $campaignId);
         $this->assertEmpty($campaignItems);
     }
     $this->assertTrue(CampaignItemsUtil::generateCampaignItemsForDueCampaigns(5));
     foreach ($campaignIds as $index => $campaignId) {
         $campaign = Campaign::getById($campaignId);
         $campaignItems = CampaignItem::getByProcessedAndCampaignId(0, $campaignId);
         if ($index === 0) {
             $expectedCount = AutoresponderOrCampaignBatchSizeConfigUtil::getBatchSize();
             $memberCount = count($campaign->marketingList->marketingListMembers);
             if ($memberCount < $expectedCount) {
                 $expectedCount = $memberCount;
             }
             $this->assertNotEmpty($campaignItems);
             $this->assertCount($expectedCount, $campaignItems);
             $this->assertEquals(Campaign::STATUS_PROCESSING, $campaign->status);
         } else {
             $this->assertEmpty($campaignItems);
             $this->assertEquals(Campaign::STATUS_ACTIVE, $campaign->status);
         }
     }
     $this->assertTrue(CampaignItemsUtil::generateCampaignItemsForDueCampaigns());
     foreach ($campaignIds as $index => $campaignId) {
         $campaign = Campaign::getById($campaignId);
         $campaignItems = CampaignItem::getByProcessedAndCampaignId(0, $campaignId);
         if ($index < 2) {
             $expectedCount = AutoresponderOrCampaignBatchSizeConfigUtil::getBatchSize();
             $memberCount = count($campaign->marketingList->marketingListMembers);
             if ($memberCount < $expectedCount) {
                 $expectedCount = $memberCount;
             }
             $this->assertNotEmpty($campaignItems);
             $this->assertCount($expectedCount, $campaignItems);
             $this->assertEquals(Campaign::STATUS_PROCESSING, $campaign->status);
         } else {
             $this->assertEmpty($campaignItems);
             $this->assertEquals(Campaign::STATUS_ACTIVE, $campaign->status);
         }
     }
     // TODO: @Shoaibi: Medium: Add tests for the other campaign type.
 }