/**
  * @depends testValidate
  */
 public function testMissingEmailTemplateWillNotValidate()
 {
     $message = new EmailMessageForWorkflowForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE);
     $message->sendAfterDurationSeconds = 86400;
     $message->sendFromType = EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
     $recipients = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER, 'audienceType' => EmailMessageRecipient::TYPE_TO, 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_CREATED_BY_USER));
     $message->setAttributes(array(EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS => $recipients));
     $validated = $message->validate();
     $errors = $message->getErrors();
     $this->assertFalse($validated);
     $compareErrors = array('emailTemplateId' => array('Template cannot be blank.'));
     $this->assertEquals($compareErrors, $errors);
     //Now fill in emailTemplateId and it should pass
     $message->emailTemplateId = 5;
     $validated = $message->validate();
     $this->assertTrue($validated);
 }
 protected function registerAddRecipientScript()
 {
     $moduleClassNameId = $this->workflowWizardFormClassName . '[moduleClassName]';
     $url = Yii::app()->createUrl('workflows/default/addEmailMessageRecipient', array_merge($_GET, array('type' => $this->model->getWorkflowType())));
     // Begin Not Coding Standard
     $ajaxSubmitScript = ZurmoHtml::ajax(array('type' => 'GET', 'data' => 'js:\'recipientType=\' + $(this).val() + ' . '\'&moduleClassName=\' + $("input:radio[name=\\"' . $moduleClassNameId . '\\"]:checked").val() + ' . '\'&rowNumber=\' + ($(this).parentsUntil(".' . self::RECIPIENTS_CONTAINER_CLASS_NAME . '").parent().find("input.' . self::RECIPIENTS_ROW_COUNTER_CLASS_NAME . '").data("email-row-number")) + ' . '\'&recipientRowNumber=\' +
                          $(this).parentsUntil(".' . self::RECIPIENTS_CONTAINER_CLASS_NAME . '").parent().find(".' . self::RECIPIENTS_ROW_COUNTER_CLASS_NAME . '").val()', 'url' => $url, 'success' => 'js:function(data){
                 existingRowNumber = parseInt(triggeredObject.parentsUntil(".' . self::RECIPIENTS_CONTAINER_CLASS_NAME . '").parent().
                 find(".' . self::RECIPIENTS_ROW_COUNTER_CLASS_NAME . '").val());
                 triggeredObject.parentsUntil(".' . self::RECIPIENTS_CONTAINER_CLASS_NAME . '").parent().
                 find(".' . self::RECIPIENTS_ROW_COUNTER_CLASS_NAME . '")
                 .val(existingRowNumber + 1);
                 triggeredObject.parentsUntil(".' . self::RECIPIENTS_CONTAINER_CLASS_NAME . '").parent()
                 .find(".' . self::EMAIL_MESSAGE_RECIPIENTS_ROW_CLASS_NAME . '").find("ul:first").append(data);
                 rebuildWorkflowEmailMessageRecipientRowNumbers(triggeredObject.
                     parentsUntil(".' . self::RECIPIENTS_CONTAINER_CLASS_NAME . '").parent()
                     .find(".' . self::EMAIL_MESSAGE_RECIPIENTS_ROW_CLASS_NAME . '"));
                 triggeredObject.val("");
             }'));
     $script = "\$('." . self::ADD_RECIPIENT_CLASS_NAME . "').unbind('change');\n                       \$('." . self::ADD_RECIPIENT_CLASS_NAME . "').bind('change', function()\n                        {\n                            if (\$(this).val() != '')\n                            {\n                                var triggeredObject = \$(this);\n                                {$ajaxSubmitScript}\n                            }\n                        });";
     // End Not Coding Standard
     Yii::app()->clientScript->registerScript('workflowAddEmailMessageRecipientScript', $script);
 }
 /**
  * @param WorkflowMessageInQueue $workflowMessageInQueue
  * @param Workflow $workflow
  * @return EmailMessageForWorkflowForm
  */
 public static function makeEmailMessageForWorkflowFormByQueueModelAndWorkflow(WorkflowMessageInQueue $workflowMessageInQueue, Workflow $workflow)
 {
     $moduleClassName = $workflow->getModuleClassName();
     $emailMessageForWorkflowForm = new EmailMessageForWorkflowForm($moduleClassName::getPrimaryModelName(), $workflow->getType(), 0);
     $unserializedData = unserialize($workflowMessageInQueue->serializedData);
     $emailMessageForWorkflowForm->setAttributes(reset($unserializedData));
     return $emailMessageForWorkflowForm;
 }
    protected function makeSampleOnSaveWorkflow()
    {
        Yii::app()->user->userModel = User::getByUsername('super');
        $emailTemplate = new EmailTemplate();
        $emailTemplate->type = EmailTemplate::TYPE_WORKFLOW;
        $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_BUILDER_TEMPLATE;
        $emailTemplate->subject = 'We closed a deal';
        $emailTemplate->name = 'We closed a deal - Sample Email Template';
        $emailTemplate->textContent = 'Hello!!!
We just closed new deal, please check details: [[MODEL^URL]]
Thanks!';
        $emailTemplate->htmlContent = '<p>Hello!!!</p>
<p>We just closed new deal, please check details: [[MODEL^URL]]</p>
<p>Thanks!</p>';
        $emailTemplate->modelClassName = 'Opportunity';
        $emailTemplate->isDraft = false;
        $emailTemplate->save();
        $trigger = new TriggerForWorkflowForm('OpportunitiesModule', 'Opportunity', Workflow::TYPE_ON_SAVE);
        $trigger->attributeIndexOrDerivedType = 'stage';
        $trigger->value = 'Closed Won';
        $trigger->operator = OperatorRules::TYPE_BECOMES;
        $trigger->relationFilter = TriggerForWorkflowForm::RELATION_FILTER_ANY;
        $message = new EmailMessageForWorkflowForm('Opportunity', Workflow::TYPE_ON_SAVE);
        $message->sendAfterDurationInterval = 0;
        $message->sendAfterDurationType = TimeDurationUtil::DURATION_TYPE_MINUTE;
        $message->emailTemplateId = $emailTemplate->id;
        $message->sendFromType = EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
        $recipients = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_STATIC_ADDRESS, 'audienceType' => EmailMessageRecipient::TYPE_TO, 'toName' => 'The Sales Team', 'toAddress' => '*****@*****.**'));
        $message->setAttributes(array(EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS => $recipients));
        $workflow = new Workflow();
        $workflow->setDescription('This will send an email to recipients that you choose when you close a deal!');
        $workflow->setIsActive(false);
        $workflow->setOrder(2);
        $workflow->setModuleClassName('OpportunitiesModule');
        $workflow->setName('Closed won Opportunity alert');
        $workflow->setTriggerOn(Workflow::TRIGGER_ON_NEW_AND_EXISTING);
        $workflow->setType(Workflow::TYPE_ON_SAVE);
        $workflow->setTriggersStructure('1');
        $workflow->addTrigger($trigger);
        $workflow->addEmailMessage($message);
        $savedWorkflow = new SavedWorkflow();
        SavedWorkflowToWorkflowAdapter::resolveWorkflowToSavedWorkflow($workflow, $savedWorkflow);
        $savedWorkflow->save();
    }
 /**
  * To try to show failure of https://www.pivotaltracker.com/story/show/81571830
  * Using trademark symbol to demonstrate merge tag resolution working correctly and it properly printing
  * text after the trademark symbol
  */
 public function testNonAlphaNumericSymbolsAsMergeTagFields()
 {
     $account = AccountTestHelper::createAccountByNameForOwner('Candyland™', Yii::app()->user->userModel);
     $emailTemplate = new EmailTemplate();
     $emailTemplate->builtType = EmailTemplate::BUILT_TYPE_PASTED_HTML;
     $emailTemplate->modelClassName = 'Account';
     $emailTemplate->type = 1;
     $emailTemplate->name = 'some template';
     $emailTemplate->subject = 'some subject [[NAME]] is great';
     $emailTemplate->htmlContent = 'Account HTML: [[NAME]] after the merge tag is resolved';
     $emailTemplate->textContent = 'Account Text: [[NAME]] after the merge tag is resolved';
     $this->assertTrue($emailTemplate->save());
     $message = new EmailMessageForWorkflowForm('Account', Workflow::TYPE_ON_SAVE);
     $recipients = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER, 'audienceType' => EmailMessageRecipient::TYPE_TO, 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_CREATED_BY_USER));
     $message->emailTemplateId = $emailTemplate->id;
     $message->sendFromType = EmailMessageForWorkflowForm::SEND_FROM_TYPE_CUSTOM;
     $message->sendFromAddress = '*****@*****.**';
     $message->sendFromName = 'Jason';
     $message->setAttributes(array(EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS => $recipients));
     $helper = new WorkflowEmailMessageProcessingHelper($message, $account, Yii::app()->user->userModel);
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $helper->process();
     $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $emailMessages = EmailMessage::getAllByFolderType(EmailFolder::TYPE_OUTBOX);
     $this->assertEquals('some subject Candyland™ is great', $emailMessages[0]->subject);
     $this->assertEquals('Account Text: Candyland™ after the merge tag is resolved', $emailMessages[0]->content->textContent);
     $this->assertEquals('Account HTML: Candyland™ after the merge tag is resolved', $emailMessages[0]->content->htmlContent);
 }
 /**
  * @depends testProcessWithCustomSender
  */
 public function testInvalidMergeTagsReturnOriginalContent()
 {
     self::$emailTemplate->subject = 'bad subject [[LASTNAME]]';
     self::$emailTemplate->textContent = 'bad text [[LASTNAME]]';
     self::$emailTemplate->htmlContent = 'bad html [[LASTNAME]]';
     $message = new EmailMessageForWorkflowForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE);
     $recipients = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER, 'audienceType' => EmailMessageRecipient::TYPE_TO, 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_CREATED_BY_USER));
     $message->emailTemplateId = self::$emailTemplate->id;
     $message->sendFromType = EmailMessageForWorkflowForm::SEND_FROM_TYPE_CUSTOM;
     $message->sendFromAddress = '*****@*****.**';
     $message->sendFromName = 'Jason';
     $message->setAttributes(array(EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS => $recipients));
     $model = new WorkflowModelTestItem();
     $model->lastName = 'the lastName';
     $model->string = 'the string';
     $model->phone = 'the phone';
     $saved = $model->save();
     $this->assertTrue($saved);
     $helper = new WorkflowEmailMessageProcessingHelper($message, $model, Yii::app()->user->userModel);
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $helper->process();
     $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $emailMessages = EmailMessage::getAllByFolderType(EmailFolder::TYPE_OUTBOX);
     $this->assertEquals('bad subject [[LASTNAME]]', $emailMessages[0]->subject);
     $this->assertEquals('bad text [[LASTNAME]]', $emailMessages[0]->content->textContent);
     $this->assertEquals('bad html [[LASTNAME]]', $emailMessages[0]->content->htmlContent);
     $this->assertEquals('Jason', $emailMessages[0]->sender->fromName);
     $this->assertEquals('*****@*****.**', $emailMessages[0]->sender->fromAddress);
     $this->assertEquals(1, $emailMessages[0]->recipients->count());
     $this->assertEquals('*****@*****.**', $emailMessages[0]->recipients[0]->toAddress);
     $emailMessages[0]->delete();
 }
 /**
  * Public for testing purposes
  * @param array $data
  * @param Workflow $workflow
  */
 public static function resolveEmailMessages($data, Workflow $workflow)
 {
     assert('is_array($data)');
     $workflow->removeAllEmailMessages();
     $moduleClassName = $workflow->getModuleClassName();
     if (count($emailMessagesData = ArrayUtil::getArrayValue($data, ComponentForWorkflowForm::TYPE_EMAIL_MESSAGES)) > 0) {
         foreach ($emailMessagesData as $key => $emailMessageData) {
             $emailMessage = new EmailMessageForWorkflowForm($moduleClassName::getPrimaryModelName(), $workflow->type, $key);
             $emailMessage->setAttributes($emailMessageData);
             $workflow->addEmailMessage($emailMessage);
         }
     } else {
         $workflow->removeAllEmailMessages();
     }
 }
 /**
  * @param array $componentFormsData
  * @param Workflow $workflow
  */
 protected static function makeEmailMessageForWorkflowFormAndPopulateWorkflowFromData($componentFormsData, Workflow $workflow)
 {
     assert('is_array($componentFormsData)');
     $moduleClassName = $workflow->getModuleClassName();
     $rowKey = 0;
     foreach ($componentFormsData as $componentFormData) {
         $component = new EmailMessageForWorkflowForm($moduleClassName::getPrimaryModelName(), $workflow->getType(), $rowKey);
         $component->setAttributes($componentFormData);
         $workflow->addEmailMessage($component);
         $rowKey++;
     }
 }
 public function testProcessAfterSaveWhenSendIsImmediateAndToAContactThatIsRelatedToTheTriggeredModel()
 {
     foreach (EmailMessage::getAll() as $emailMessage) {
         $emailMessage->delete();
     }
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $emailTemplate = new EmailTemplate();
     $emailTemplate->name = 'the name';
     $emailTemplate->modelClassName = 'Account';
     $emailTemplate->textContent = 'some content';
     $emailTemplate->type = 2;
     $emailTemplate->subject = 'subject';
     $saved = $emailTemplate->save();
     $this->assertTrue($saved);
     $workflow = new Workflow();
     $workflow->setId(self::$savedWorkflow->id);
     $workflow->type = Workflow::TYPE_ON_SAVE;
     $emailMessageForm = new EmailMessageForWorkflowForm('Account', Workflow::TYPE_ON_SAVE);
     $emailMessageForm->sendAfterDurationSeconds = 0;
     $emailMessageForm->emailTemplateId = $emailTemplate->id;
     $emailMessageForm->sendFromType = EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
     $recipients = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_RELATION, 'audienceType' => EmailMessageRecipient::TYPE_TO, 'relation' => 'contacts'));
     $emailMessageForm->setAttributes(array(EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS => $recipients));
     $workflow->addEmailMessage($emailMessageForm);
     $model = new Account();
     $model->name = 'the account';
     $contact = new Contact();
     $contact->firstName = 'Jason';
     $contact->lastName = 'Blue';
     $contact->state = ContactsUtil::getStartingState();
     $contact->primaryEmail->emailAddress = '*****@*****.**';
     $this->assertTrue($contact->save());
     $contact2 = new Contact();
     $contact2->firstName = 'Laura';
     $contact2->lastName = 'Blue';
     $contact2->state = ContactsUtil::getStartingState();
     $contact2->primaryEmail->emailAddress = '*****@*****.**';
     $this->assertTrue($contact2->save());
     $model->contacts->add($contact);
     $model->contacts->add($contact2);
     $this->assertTrue($model->save());
     WorkflowEmailMessagesUtil::processAfterSave($workflow, $model, Yii::app()->user->userModel);
     $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $queuedEmailMessages = EmailMessage::getAllByFolderType(EmailFolder::TYPE_OUTBOX);
     $this->assertEquals(1, count($queuedEmailMessages));
     $this->assertEquals(2, count($queuedEmailMessages[0]->recipients));
     $this->assertEquals('Jason Blue', $queuedEmailMessages[0]->recipients[0]->toName);
     $this->assertEquals('*****@*****.**', $queuedEmailMessages[0]->recipients[0]->toAddress);
     $this->assertEquals($contact->id, $queuedEmailMessages[0]->recipients[0]->personOrAccount->id);
     $this->assertEquals('Laura Blue', $queuedEmailMessages[0]->recipients[1]->toName);
     $this->assertEquals('*****@*****.**', $queuedEmailMessages[0]->recipients[1]->toAddress);
     $this->assertEquals($contact2->id, $queuedEmailMessages[0]->recipients[1]->personOrAccount->id);
 }
 public function testResolveNewTimeStampForDuration()
 {
     $message = new EmailMessageForWorkflowForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE);
     $message->sendAfterDurationInterval = 5;
     $message->sendAfterDurationType = TimeDurationUtil::DURATION_TYPE_DAY;
     $this->assertEquals(5 * 24 * 60 * 60, $message->resolveNewTimeStampForDuration(0));
     $message->sendAfterDurationType = TimeDurationUtil::DURATION_TYPE_MINUTE;
     $this->assertEquals(5 * 60, $message->resolveNewTimeStampForDuration(0));
     $message->sendAfterDurationInterval = 10;
     $this->assertEquals(10 * 60, $message->resolveNewTimeStampForDuration(0));
     $message->sendAfterDurationType = TimeDurationUtil::DURATION_TYPE_HOUR;
     $this->assertEquals(10 * 60 * 60, $message->resolveNewTimeStampForDuration(0));
 }
 public function testResolveWorkflowToSavedWorkflow()
 {
     $workflow = new Workflow();
     $workflow->setDescription('aDescription');
     $workflow->setIsActive(true);
     $workflow->setOrder(5);
     $workflow->setModuleClassName('WorkflowsTestModule');
     $workflow->setName('myFirstWorkflow');
     $workflow->setTriggerOn(Workflow::TRIGGER_ON_NEW);
     $workflow->setType(Workflow::TYPE_ON_SAVE);
     $workflow->setTriggersStructure('1 and 2 or 3 or 4');
     $trigger = new TriggerForWorkflowForm('WorkflowsTestModule', 'WorkflowModelTestItem', $workflow->getType());
     $trigger->attributeIndexOrDerivedType = 'string';
     $trigger->value = 'aValue';
     $trigger->operator = 'equals';
     $workflow->addTrigger($trigger);
     $trigger = new TriggerForWorkflowForm('WorkflowsTestModule', 'WorkflowModelTestItem', $workflow->getType());
     $trigger->attributeIndexOrDerivedType = 'currencyValue';
     $trigger->value = 'aValue';
     $trigger->secondValue = 'bValue';
     $trigger->operator = 'between';
     $trigger->currencyIdForValue = '4';
     $workflow->addTrigger($trigger);
     $trigger = new TriggerForWorkflowForm('WorkflowsTestModule', 'WorkflowModelTestItem', $workflow->getType());
     $trigger->attributeIndexOrDerivedType = 'owner__User';
     $trigger->value = 'aValue';
     $trigger->stringifiedModelForValue = 'someName';
     $workflow->addTrigger($trigger);
     $trigger = new TriggerForWorkflowForm('WorkflowsTestModule', 'WorkflowModelTestItem', $workflow->getType());
     $trigger->attributeIndexOrDerivedType = 'createdDateTime';
     $trigger->value = 'aValue';
     $trigger->secondValue = 'bValue';
     $trigger->operator = null;
     $trigger->currencyIdForValue = null;
     $trigger->valueType = 'Between';
     $workflow->addTrigger($trigger);
     $trigger = new TimeTriggerForWorkflowForm('WorkflowsTestModule', 'WorkflowModelTestItem', $workflow->getType());
     $trigger->attributeIndexOrDerivedType = 'date';
     $trigger->durationInterval = 500;
     $trigger->valueType = 'Is Time For';
     $workflow->setTimeTrigger($trigger);
     $action = new ActionForWorkflowForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE);
     $action->type = ActionForWorkflowForm::TYPE_UPDATE_SELF;
     $attributes = array('string' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'jason'));
     $action->setAttributes(array(ActionForWorkflowForm::ACTION_ATTRIBUTES => $attributes));
     $workflow->addAction($action);
     $message = new EmailMessageForWorkflowForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE);
     $message->sendAfterDurationInterval = 86400;
     $message->sendAfterDurationType = TimeDurationUtil::DURATION_TYPE_WEEK;
     $message->emailTemplateId = 5;
     $message->sendFromType = EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
     $recipients = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER, 'audienceType' => EmailMessageRecipient::TYPE_TO, 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_CREATED_BY_USER));
     $message->setAttributes(array(EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS => $recipients));
     $workflow->addEmailMessage($message);
     $savedWorkflow = new SavedWorkflow();
     $this->assertNull($savedWorkflow->serializedData);
     SavedWorkflowToWorkflowAdapter::resolveWorkflowToSavedWorkflow($workflow, $savedWorkflow);
     $this->assertEquals('WorkflowsTestModule', $savedWorkflow->moduleClassName);
     $this->assertEquals('1', $savedWorkflow->isActive);
     $this->assertEquals('myFirstWorkflow', $savedWorkflow->name);
     $this->assertEquals('aDescription', $savedWorkflow->description);
     $this->assertEquals(5, $savedWorkflow->order);
     $this->assertEquals(Workflow::TRIGGER_ON_NEW, $savedWorkflow->triggerOn);
     $this->assertEquals(Workflow::TYPE_ON_SAVE, $savedWorkflow->type);
     $this->assertEquals('1 and 2 or 3 or 4', $workflow->getTriggersStructure());
     $compareData = array('Triggers' => array(array('currencyIdForValue' => null, 'value' => 'aValue', 'secondValue' => null, 'stringifiedModelForValue' => null, 'valueType' => null, 'attributeIndexOrDerivedType' => 'string', 'operator' => 'equals', 'relationFilter' => TriggerForWorkflowForm::RELATION_FILTER_ANY), array('currencyIdForValue' => '4', 'value' => 'aValue', 'secondValue' => 'bValue', 'stringifiedModelForValue' => null, 'valueType' => null, 'attributeIndexOrDerivedType' => 'currencyValue', 'operator' => 'between', 'relationFilter' => TriggerForWorkflowForm::RELATION_FILTER_ANY), array('currencyIdForValue' => null, 'value' => 'aValue', 'secondValue' => null, 'stringifiedModelForValue' => 'someName', 'valueType' => null, 'attributeIndexOrDerivedType' => 'owner__User', 'operator' => null, 'relationFilter' => TriggerForWorkflowForm::RELATION_FILTER_ANY), array('value' => 'aValue', 'secondValue' => 'bValue', 'stringifiedModelForValue' => null, 'valueType' => 'Between', 'attributeIndexOrDerivedType' => 'createdDateTime', 'operator' => null, 'currencyIdForValue' => null, 'relationFilter' => TriggerForWorkflowForm::RELATION_FILTER_ANY)));
     $compareData['Actions'] = array(array('type' => ActionForWorkflowForm::TYPE_UPDATE_SELF, 'relation' => null, 'relationFilter' => ActionForWorkflowForm::RELATION_FILTER_ALL, 'relatedModelRelation' => null, 'ActionAttributes' => array('string' => array('type' => 'Static', 'value' => 'jason', 'shouldSetValue' => 1))));
     $compareData['EmailMessages'] = array(array('emailTemplateId' => 5, 'sendAfterDurationInterval' => 86400, 'sendAfterDurationType' => TimeDurationUtil::DURATION_TYPE_WEEK, 'sendFromType' => 'Default', 'sendFromName' => null, 'sendFromAddress' => null, 'EmailMessageRecipients' => array(array('dynamicUserType' => 'CreatedByUser', 'type' => 'DynamicTriggeredModelUser', 'audienceType' => 1))));
     $compareData['TimeTrigger'] = array('durationInterval' => 500, 'durationSign' => TimeDurationUtil::DURATION_SIGN_POSITIVE, 'durationType' => TimeDurationUtil::DURATION_TYPE_DAY, 'currencyIdForValue' => null, 'value' => null, 'secondValue' => null, 'valueType' => 'Is Time For', 'relationFilter' => 'RelationFilterAny', 'attributeIndexOrDerivedType' => 'date', 'operator' => null);
     $unserializedData = unserialize($savedWorkflow->serializedData);
     $this->assertEquals($compareData['Triggers'], $unserializedData['Triggers']);
     $this->assertEquals($compareData['Actions'], $unserializedData['Actions']);
     $this->assertEquals($compareData['EmailMessages'], $unserializedData['EmailMessages']);
     $this->assertEquals($compareData['TimeTrigger'], $unserializedData['TimeTrigger']);
     $this->assertEquals('1 and 2 or 3 or 4', $unserializedData['triggersStructure']);
     $saved = $savedWorkflow->save();
     $this->assertTrue($saved);
 }