/**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof ContactWebFormEntry');
     parent::populateModel($model);
     if (empty($this->seedData)) {
         $this->seedData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ContactWebFormsModule', 'ContactWebFormEntry');
     }
     $contactFormAttributes = array();
     $contact = new Contact();
     $contact->owner = $model->contactWebForm->defaultOwner;
     $contact->state = $model->contactWebForm->defaultState;
     $contact->firstName = $contactFormAttributes['firstName'] = $this->seedData['firstName'][$this->index];
     $contact->lastName = $contactFormAttributes['lastName'] = $this->seedData['lastName'][$this->index];
     $contact->companyName = $contactFormAttributes['companyName'] = $this->seedData['companyName'][$this->index];
     $contact->jobTitle = $contactFormAttributes['jobTitle'] = $this->seedData['jobTitle'][$this->index];
     if ($contact->validate()) {
         $contactWebFormEntryStatus = ContactWebFormEntry::STATUS_SUCCESS;
         $contactWebFormEntryMessage = ContactWebFormEntry::STATUS_SUCCESS_MESSAGE;
         $contact->save();
     } else {
         $contactWebFormEntryStatus = ContactWebFormEntry::STATUS_ERROR;
         $contactWebFormEntryMessage = ContactWebFormEntry::STATUS_ERROR_MESSAGE;
         $contact = null;
     }
     $model->contact = $contact;
     $model->status = $contactWebFormEntryStatus;
     $model->message = $contactWebFormEntryMessage;
     $contactFormAttributes['owner'] = $model->contactWebForm->defaultOwner->id;
     $contactFormAttributes['state'] = $model->contactWebForm->defaultState->id;
     $model->serializedData = serialize($contactFormAttributes);
 }
Example #2
0
 public function populateModel(&$model)
 {
     //todo: assert instanceof Person or mixes in Person.
     parent::populateModel($model);
     $personRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ZurmoModule', 'Person');
     $jobTitlesAndDepartments = RandomDataUtil::getRandomValueFromArray($personRandomData['jobTitlesAndDepartments']);
     $lastName = RandomDataUtil::getRandomValueFromArray($personRandomData['lastNames']);
     if ($model->firstName == null && RandomDataUtil::getRandomBooleanValue()) {
         $model->firstName = RandomDataUtil::getRandomValueFromArray($personRandomData['femaleFirstNames']);
         $title = RandomDataUtil::getRandomValueFromArray($personRandomData['femaleTitles']);
     } elseif ($model->firstName == null) {
         $model->firstName = RandomDataUtil::getRandomValueFromArray($personRandomData['maleFirstNames']);
         $title = RandomDataUtil::getRandomValueFromArray($personRandomData['maleTitles']);
     }
     if ($model->lastName == null) {
         $model->lastName = $lastName;
     }
     $model->title->value = $title;
     $model->jobTitle = $jobTitlesAndDepartments[0];
     $model->department = $jobTitlesAndDepartments[1];
     $model->officePhone = RandomDataUtil::makeRandomPhoneNumber();
     $model->officeFax = RandomDataUtil::makeRandomPhoneNumber();
     $model->mobilePhone = RandomDataUtil::makeRandomPhoneNumber();
     $model->primaryEmail = static::makeEmailAddressByPerson($model);
     $model->primaryAddress = ZurmoRandomDataUtil::makeRandomAddress();
 }
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("User")');
     $gameRewards = array();
     $gameRewardRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('GameRewardsModule', 'GameReward');
     for ($i = 0; $i < 10; $i++) {
         $gameReward = new GameReward();
         $gameReward->name = $gameRewardRandomData['names'][$i];
         $gameReward->owner = $demoDataHelper->getRandomByModelName('User');
         $gameReward->cost = mt_rand(1, 10);
         $gameReward->quantity = mt_rand(1, 20);
         for ($j = 0; $j < 5; $j++) {
             $gameRewardTransaction = new GameRewardTransaction();
             $gameRewardTransaction->person = $demoDataHelper->getRandomByModelName('User');
             $gameRewardTransaction->quantity = mt_rand(1, 3);
             $gameReward->transactions->add($gameRewardTransaction);
         }
         $gameReward->addPermissions(Group::getByName(Group::EVERYONE_GROUP_NAME), Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
         $saved = $gameReward->save();
         if (!$saved) {
             throw new FailedToSaveModelException();
         }
         $gameReward = GameReward::getById($gameReward->id);
         AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($gameReward, Group::getByName(Group::EVERYONE_GROUP_NAME));
         $gameReward->save();
         $gameRewards[] = $gameReward->id;
     }
     $demoDataHelper->setRangeByModelName('GameReward', $gameRewards[0], $gameRewards[count($gameRewards) - 1]);
 }
 public function populateModel(&$model)
 {
     assert('$model instanceof Contact');
     parent::populateModel($model);
     $accountRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('AccountsModule', 'Account');
     $name = RandomDataUtil::getRandomValueFromArray($accountRandomData['names']);
     $model->companyName = $name;
 }
 /**
  * @param $model
  * @param $counter
  */
 public function populateModelData(&$model, $counter)
 {
     assert('$model instanceof ProductCategory');
     parent::populateModel($model);
     $productCategoryRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ProductTemplatesModule', 'ProductCategory');
     $name = $productCategoryRandomData['names'][$counter];
     $model->name = $name;
 }
 /**
  * Populate model with required data
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof Project');
     parent::populateModel($model);
     $projectRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ProjectsModule', 'Project');
     $name = RandomDataUtil::getRandomValueFromArray($projectRandomData['names']);
     $model->name = $name;
     $model->description = $name . ' Description';
 }
 public function testDemoDataMaker()
 {
     $productCategory = new ProductCategory();
     $productTemplateRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ProductTemplatesModule', 'ProductCategory');
     $name = RandomDataUtil::getRandomValueFromArray($productTemplateRandomData['names']);
     $productCategory->name = $name;
     $this->assertTrue($productCategory->save());
     $productCategories[] = $productCategory->id;
 }
 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof Note');
     parent::populateModel($model);
     $taskRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('NotesModule', 'Note');
     $description = RandomDataUtil::getRandomValueFromArray($taskRandomData['descriptions']);
     $occurredOnTimeStamp = time() - mt_rand(1, 200) * 60 * 60 * 24;
     $occurredOnDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($occurredOnTimeStamp);
     $model->description = $description;
     $model->occurredOnDateTime = $occurredOnDateTime;
 }
 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof MarketingList');
     parent::populateModel($model);
     if (empty($this->seedData)) {
         $this->seedData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('MarketingListsModule', 'MarketingList');
     }
     $model->name = $this->seedData['name'][$this->index];
     $model->description = $this->seedData['description'][$this->index];
     $model->fromName = $this->seedData['fromName'][$this->index];
     $model->fromAddress = $this->seedData['fromAddress'][$this->index];
     $model->anyoneCanSubscribe = rand(10, 20) % 2;
 }
 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof ContactWebForm');
     parent::populateModel($model);
     if (empty($this->seedData)) {
         $this->seedData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ContactWebFormsModule', 'ContactWebForm');
     }
     $model->name = $this->seedData['name'][$this->index];
     $model->redirectUrl = $this->seedData['redirectUrl'][$this->index];
     $model->submitButtonLabel = $this->seedData['submitButtonLabel'][$this->index];
     $placedAttributes = array('firstName', 'lastName', 'companyName', 'jobTitle');
     $model->serializedData = serialize($placedAttributes);
 }
 /**
  * Make an Address object.
  */
 public static function makeRandomAddress()
 {
     $addressRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ZurmoModule', 'Address');
     $streetName = RandomDataUtil::getRandomValueFromArray($addressRandomData['streetNames']);
     $direction = RandomDataUtil::getRandomValueFromArray($addressRandomData['directions']);
     $streetSuffix = RandomDataUtil::getRandomValueFromArray($addressRandomData['streetSuffixes']);
     $cityStatePostalCodeData = RandomDataUtil::getRandomValueFromArray($addressRandomData['cityStatePostalCode']);
     $address = new Address();
     $address->street1 = mt_rand(1000, 40000) . ' ' . $direction . ' ' . $streetName . ' ' . $streetSuffix;
     $address->city = $cityStatePostalCodeData[0];
     $address->state = $cityStatePostalCodeData[1];
     $address->postalCode = RandomDataUtil::getRandomValueFromArray($cityStatePostalCodeData[2]);
     return $address;
 }
 public function populateModel(&$model)
 {
     assert('$model instanceof Autoresponder');
     parent::populateModel($model);
     if (empty($this->seedData)) {
         $this->seedData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('AutorespondersModule', 'Autoresponder');
     }
     $model->subject = $this->seedData['subject'][$this->index];
     $model->htmlContent = $this->seedData['htmlContent'][$this->index];
     $model->textContent = $this->seedData['textContent'][$this->index];
     $model->secondsFromOperation = $this->seedData['secondsFromOperation'][$this->index];
     $model->operationType = $this->seedData['operationType'][$this->index];
     $model->enableTracking = rand() % 2;
     $this->populateMarketingModelWithFiles($model);
 }
 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof Opportunity');
     $opportunityRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('OpportunitiesModule', 'Opportunity');
     parent::populateModel($model);
     $name = RandomDataUtil::getRandomValueFromArray($opportunityRandomData['names']);
     $model->name = $name;
     $stage = RandomDataUtil::getRandomValueFromArray(static::getCustomFieldDataByName('SalesStages'));
     $source = RandomDataUtil::getRandomValueFromArray(static::getCustomFieldDataByName('LeadSources'));
     $model->stage->value = $stage;
     $model->source->value = $source;
     $futureTimeStamp = time() + mt_rand(1, 200) * 60 * 60 * 24;
     $closeDate = Yii::app()->dateFormatter->format(DatabaseCompatibilityUtil::getDateFormat(), $futureTimeStamp);
     $model->closeDate = $closeDate;
     $model->amount->value = mt_rand(5, 350) * 1000;
 }
Example #14
0
 public function populateModel(&$model)
 {
     assert('$model instanceof Task');
     parent::populateModel($model);
     $taskRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('TasksModule', 'Task');
     $name = RandomDataUtil::getRandomValueFromArray($taskRandomData['names']);
     if (RandomDataUtil::getRandomBooleanValue()) {
         $dueTimeStamp = time() - mt_rand(1, 50) * 60 * 60 * 24;
         $completedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($dueTimeStamp + mt_rand(1, 24) * 15);
         $model->completedDateTime = $completedDateTime;
         $model->completed = true;
     } else {
         $dueTimeStamp = time() + mt_rand(1, 200) * 60 * 60 * 24;
     }
     $dueDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($dueTimeStamp);
     $model->name = $name;
     $model->dueDateTime = $dueDateTime;
 }
 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof Account');
     parent::populateModel($model);
     $accountRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('AccountsModule', 'Account');
     $name = RandomDataUtil::getRandomValueFromArray($accountRandomData['names']);
     $domainName = static::makeDomainByName(strval($model));
     $type = RandomDataUtil::getRandomValueFromArray(static::getCustomFieldDataByName('AccountTypes'));
     $industry = RandomDataUtil::getRandomValueFromArray(static::getCustomFieldDataByName('Industries'));
     $model->name = $name;
     $model->website = static::makeUrlByDomainName($domainName);
     $model->type->value = $type;
     $model->industry->value = $industry;
     $model->officePhone = RandomDataUtil::makeRandomPhoneNumber();
     $model->officeFax = RandomDataUtil::makeRandomPhoneNumber();
     $model->primaryEmail = static::makeEmailAddressByAccount($model);
     $model->billingAddress = ZurmoRandomDataUtil::makeRandomAddress();
     $model->employees = mt_rand(1, 95) * 10;
     $model->annualRevenue = mt_rand(1, 780) * 1000000;
 }
 public function populateModel(&$model)
 {
     assert('$model instanceof EmailTemplate');
     parent::populateModel($model);
     if (empty($this->seedData)) {
         $this->seedData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('EmailTemplatesModule', 'EmailTemplate');
     }
     $modelClassName = 'Contact';
     if ($model->type === EmailTemplate::TYPE_WORKFLOW) {
         $modelClassName = $this->seedData['modelClassName'][$this->index];
     }
     $model->modelClassName = $modelClassName;
     $model->name = $this->seedData['name'][$this->index];
     $model->subject = $this->seedData['subject'][$this->index];
     $model->language = $this->seedData['language'][0];
     if (isset($this->seedData['language'][$this->index])) {
         $model->language = $this->seedData['language'][$this->index];
     }
     $model->textContent = $this->seedData['textContent'][$this->index % 2];
     $model->htmlContent = $this->seedData['htmlContent'][$this->index % 2];
     $this->populateMarketingModelWithFiles($model);
 }
 public function populateModel(&$model, $setInFuture = true)
 {
     assert('$model instanceof Meeting');
     parent::populateModel($model);
     $meetingRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('MeetingsModule', 'Meeting');
     $name = RandomDataUtil::getRandomValueFromArray($meetingRandomData['names']);
     $category = RandomDataUtil::getRandomValueFromArray(static::getCustomFieldDataByName('MeetingCategories'));
     $location = RandomDataUtil::getRandomValueFromArray($meetingRandomData['locations']);
     if ($setInFuture) {
         $startTimeStamp = time() + mt_rand(1, 60) * 60 * 60 * 24;
         $startDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($startTimeStamp);
         $endDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($startTimeStamp + mt_rand(1, 24) * 15);
     } else {
         $startTimeStamp = time() - mt_rand(1, 30) * 60 * 60 * 24;
         $startDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($startTimeStamp);
         $endDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($startTimeStamp + mt_rand(1, 24) * 15);
     }
     $model->name = $name;
     $model->category->value = $category;
     $model->location = $location;
     $model->startDateTime = $startDateTime;
     $model->endDateTime = $endDateTime;
 }
 public function populateModel(&$model)
 {
     assert('$model instanceof Campaign');
     parent::populateModel($model);
     if (empty($this->seedData)) {
         $this->seedData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('CampaignsModule', 'Campaign');
     }
     $statusKeys = array_keys(Campaign::getStatusDropDownArray());
     $timestamp = time();
     $model->name = $this->seedData['name'][$this->index];
     $model->subject = $this->seedData['subject'][$this->index];
     $model->status = RandomDataUtil::getRandomValueFromArray($statusKeys);
     if (!(rand() % 2)) {
         $timestamp += rand(500, 5000);
     }
     $model->sendOnDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($timestamp);
     $model->supportsRichText = rand() % 2;
     $model->htmlContent = $this->seedData['htmlContent'][$this->index];
     $model->textContent = $this->seedData['textContent'][$this->index];
     $model->fromName = $this->seedData['fromName'][$this->index];
     $model->fromAddress = $this->seedData['fromAddress'][$this->index];
     $model->enableTracking = rand() % 2;
     $this->populateMarketingModelWithFiles($model);
 }
 public function populateModel(&$model)
 {
     assert('$model instanceof EmailTemplate');
     parent::populateModel($model);
     if (empty($this->seedData)) {
         $this->seedData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('EmailTemplatesModule', 'EmailTemplate');
     }
     $modelClassName = 'Contact';
     if ($model->isWorkflowTemplate()) {
         $modelClassName = $this->seedData['modelClassName'][$this->index];
     }
     $model->modelClassName = $modelClassName;
     $model->name = $this->seedData['name'][$this->index];
     $model->subject = $this->seedData['subject'][$this->index];
     $model->language = $this->seedData['language'][0];
     if (isset($this->seedData['language'][$this->index])) {
         $model->language = $this->seedData['language'][$this->index];
     }
     $model->textContent = str_replace('Zurmo', Yii::app()->label, $this->seedData['textContent'][$this->index % 2]);
     $model->htmlContent = str_replace('Zurmo', Yii::app()->label, $this->seedData['htmlContent'][$this->index % 2]);
     $model->builtType = EmailTemplate::BUILT_TYPE_PASTED_HTML;
     $model->isDraft = false;
     $this->populateMarketingModelWithFiles($model);
 }
 /**
  * @depends testCreateAndGetEmailTemplateById
  */
 public function testHtmlContentGetsSavedCorrectly()
 {
     $randomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('EmailTemplatesModule', 'EmailTemplate');
     $htmlContent = $randomData['htmlContent'][count($randomData['htmlContent']) - 1];
     $emailTemplate = new EmailTemplate();
     $emailTemplate->type = EmailTemplate::TYPE_CONTACT;
     $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_PASTED_HTML;
     $emailTemplate->subject = 'Another Test subject';
     $emailTemplate->name = 'Another Test Email Template';
     $emailTemplate->textContent = 'Text Content';
     $emailTemplate->htmlContent = $htmlContent;
     $emailTemplate->modelClassName = 'Contact';
     $this->assertTrue($emailTemplate->save());
     $emailTemplateId = $emailTemplate->id;
     $emailTemplate->forgetAll();
     $emailTemplate = EmailTemplate::getById($emailTemplateId);
     $this->assertEquals($htmlContent, $emailTemplate->htmlContent);
 }
 /**
  * @depends testCreateAndGetAutoresponderById
  */
 public function testHtmlContentGetsSavedCorrectly()
 {
     $randomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('EmailTemplatesModule', 'EmailTemplate');
     $htmlContent = $randomData['htmlContent'][count($randomData['htmlContent']) - 1];
     $autoresponder = new Autoresponder();
     $autoresponder->subject = 'Another Test subject';
     $autoresponder->textContent = 'Text Content';
     $autoresponder->htmlContent = $htmlContent;
     $autoresponder->fromOperationDurationInterval = '1';
     $autoresponder->fromOperationDurationType = TimeDurationUtil::DURATION_TYPE_MONTH;
     $autoresponder->operationType = Autoresponder::OPERATION_UNSUBSCRIBE;
     $autoresponder->enableTracking = 1;
     $this->assertTrue($autoresponder->save());
     $autoresponderId = $autoresponder->id;
     $autoresponder->forgetAll();
     $autoresponder = Autoresponder::getById($autoresponderId);
     $this->assertEquals($htmlContent, $autoresponder->htmlContent);
     $this->assertEquals(4, Autoresponder::getCount());
 }
Example #22
0
 /**
  * @depends testCreateAndGetCampaignListById
  */
 public function testHtmlContentGetsSavedCorrectly()
 {
     $randomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('EmailTemplatesModule', 'EmailTemplate');
     $htmlContent = $randomData['htmlContent'][count($randomData['htmlContent']) - 1];
     $campaign = new Campaign();
     $campaign->name = 'Another Test Campaign Name';
     $campaign->supportsRichText = 0;
     $campaign->status = Campaign::STATUS_ACTIVE;
     $campaign->fromName = 'Another From Name';
     $campaign->fromAddress = '*****@*****.**';
     $campaign->fromName = 'From Name2';
     $campaign->fromAddress = '*****@*****.**';
     $campaign->subject = 'Another Test subject';
     $campaign->textContent = 'Text Content';
     $campaign->htmlContent = $htmlContent;
     $campaign->marketingList = self::$marketingList;
     $this->assertTrue($campaign->save());
     $campaignId = $campaign->id;
     $campaign->forgetAll();
     $campaign = Campaign::getById($campaignId);
     $this->assertEquals($htmlContent, $campaign->htmlContent);
 }