/**
  * Sanitize post data, specifically handling any date and date time conversions from local format to the
  * database format.
  * @param string $importRulesType
  * @param array $postMappingData
  */
 public static function sanitizePostByTypeForSavingMappingData($importRulesType, $postMappingData)
 {
     assert('is_string($importRulesType)');
     assert('is_array($postMappingData)');
     foreach ($postMappingData as $columnName => $mappingData) {
         if (!isset($mappingData['mappingRulesData'])) {
             $postMappingData[$columnName]['mappingRulesData'] = array();
         }
     }
     foreach ($postMappingData as $columnName => $mappingData) {
         foreach ($mappingData['mappingRulesData'] as $mappingRuleFormClassName => $mappingRuleFormData) {
             $model = MappingRuleFormAndElementTypeUtil::makeForm($importRulesType, $mappingData['attributeIndexOrDerivedType'], $mappingRuleFormClassName);
             foreach ($mappingRuleFormData as $attributeName => $value) {
                 if ($value !== null) {
                     if (!is_array($value)) {
                         if ($model->isAttribute($attributeName) && $model->isAttributeSafe($attributeName)) {
                             $type = ModelAttributeToMixedTypeUtil::getTypeByModelUsingValidator($model, $model::getAttributeName());
                             if ($type == 'Date') {
                                 $postMappingData[$columnName]['mappingRulesData'][$mappingRuleFormClassName][$attributeName] = DateTimeUtil::resolveValueForDateDBFormatted($value);
                             }
                             if ($type == 'DateTime' && !empty($value)) {
                                 $postMappingData[$columnName]['mappingRulesData'][$mappingRuleFormClassName][$attributeName] = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero($value);
                             }
                         }
                     }
                 }
             }
         }
     }
     return $postMappingData;
 }
 public function testSanitizePostByTypeForSavingMappingData()
 {
     $language = Yii::app()->getLanguage();
     $this->assertEquals($language, 'en');
     $postData = array('column_0' => array('attributeIndexOrDerivedType' => 'date', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => '5/4/2011'))), 'column_1' => array('attributeIndexOrDerivedType' => 'dateTime', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => '5/4/2011 5:45 PM'))));
     $sanitizedPostData = ImportWizardFormPostUtil::sanitizePostByTypeForSavingMappingData('ImportModelTestItem', $postData);
     $compareDateTime = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('5/4/2011 5:45 PM');
     $compareData = array('column_0' => array('attributeIndexOrDerivedType' => 'date', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => '2011-05-04'))), 'column_1' => array('attributeIndexOrDerivedType' => 'dateTime', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => $compareDateTime))));
     $this->assertEquals($compareData, $sanitizedPostData);
     //now do German (de) to check a different locale.
     Yii::app()->setLanguage('de');
     $postData = array('column_0' => array('attributeIndexOrDerivedType' => 'date', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => '04.05.2011'))), 'column_1' => array('attributeIndexOrDerivedType' => 'dateTime', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => '04.05.2011 17:45'))));
     $sanitizedPostData = ImportWizardFormPostUtil::sanitizePostByTypeForSavingMappingData('ImportModelTestItem', $postData);
     $compareDateTime = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('04.05.2011 17:45');
     $compareData = array('column_0' => array('attributeIndexOrDerivedType' => 'date', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => '2011-05-04'))), 'column_1' => array('attributeIndexOrDerivedType' => 'dateTime', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => $compareDateTime))));
     $this->assertEquals($compareData, $sanitizedPostData);
     //reset language back to english
     Yii::app()->setLanguage('en');
     //test sanitizing a bad datetime
     $postData = array('column_0' => array('attributeIndexOrDerivedType' => 'dateTime', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => 'wang chung'))));
     $sanitizedPostData = ImportWizardFormPostUtil::sanitizePostByTypeForSavingMappingData('ImportModelTestItem', $postData);
     $this->assertNull($sanitizedPostData['column_0']['mappingRulesData']['DefaultValueModelAttributeMappingRuleForm']['defaultValue']);
     //sanitize an empty datetime
     $postData = array('column_0' => array('attributeIndexOrDerivedType' => 'dateTime', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => ''))));
     $sanitizedPostData = ImportWizardFormPostUtil::sanitizePostByTypeForSavingMappingData('ImportModelTestItem', $postData);
     $this->assertEmpty($sanitizedPostData['column_0']['mappingRulesData']['DefaultValueModelAttributeMappingRuleForm']['defaultValue']);
 }
Пример #3
0
 public function testSanitizePostByDesignerTypeForSavingModel()
 {
     $language = Yii::app()->getLanguage();
     $this->assertEquals($language, 'en');
     $postData = array('aDate' => '5/4/11', 'aDateTime' => '5/4/11 5:45 PM');
     $sanitizedPostData = PostUtil::sanitizePostByDesignerTypeForSavingModel(new DateDateTime(), $postData);
     $compareData = array('aDate' => '2011-05-04', 'aDateTime' => DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('5/4/11 5:45 PM'));
     $this->assertEquals($compareData, $sanitizedPostData);
     $this->assertTrue(is_string($compareData['aDateTime']));
     //now do German (de) to check a different locale.
     Yii::app()->setLanguage('de');
     $postData = array('aDate' => '04.05.11', 'aDateTime' => '04.05.11 17:45');
     $sanitizedPostData = PostUtil::sanitizePostByDesignerTypeForSavingModel(new DateDateTime(), $postData);
     $compareData = array('aDate' => '2011-05-04', 'aDateTime' => DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('04.05.11 17:45'));
     $this->assertEquals($compareData, $sanitizedPostData);
     $this->assertTrue(is_string($compareData['aDateTime']));
     //reset language back to english
     Yii::app()->setLanguage('en');
     //test sanitizing a bad datetime
     $sanitizedPostData = PostUtil::sanitizePostByDesignerTypeForSavingModel(new DateDateTime(), array('aDateTime' => 'wang chung'));
     $this->assertNull($sanitizedPostData['aDateTime']);
     //sanitize an empty datetime
     $sanitizedPostData = PostUtil::sanitizePostByDesignerTypeForSavingModel(new DateDateTime(), array('aDateTime' => ''));
     $this->assertEmpty($sanitizedPostData['aDateTime']);
 }
Пример #4
0
 /**
  * @depends testPurifyHtmlAndModifyInputUsingArrayWalkRecursive
  */
 public function testSanitizeDataByDesignerTypeForSavingModel()
 {
     $data = array('firstName' => 'Steve', 'lastName' => 'Thunder<SCRIPT>alert(\'XSS\')</SCRIPT>', 'boolean' => '0', 'date' => '3/25/11', 'dateTime' => '04/05/11 5:00 AM', 'float' => '3.68', 'integer' => '10', 'phone' => '435655', 'string' => 'some string<SCRIPT>alert(\'XSS\')</SCRIPT>', 'textArea' => 'more text here<SCRIPT>alert(\'XSS\')</SCRIPT>', 'url' => 'http://www.zurmo.org', 'dropDown' => array('value' => 'test value<SCRIPT>alert(\'XSS\')</SCRIPT>'), 'radioDropDown' => array('value' => 'my value'), 'multiDropDown' => array('values' => array('multi1', 'multi2')), 'tagCloud' => array('values' => 'tag1,tag2<SCRIPT>alert(\'XSS\')</SCRIPT>'));
     $model = new TestDataUtilModel();
     $sanitizedData = DataUtil::sanitizeDataByDesignerTypeForSavingModel($model, $data);
     $compareData = array('firstName' => 'Steve', 'lastName' => 'Thunder', 'boolean' => '0', 'date' => DateTimeUtil::resolveValueForDateDBFormatted('3/25/11'), 'dateTime' => DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('04/05/11 5:00 AM'), 'float' => '3.68', 'integer' => '10', 'phone' => '435655', 'string' => 'some string', 'textArea' => 'more text here', 'url' => 'http://www.zurmo.org', 'dropDown' => array('value' => 'test value'), 'radioDropDown' => array('value' => 'my value'), 'multiDropDown' => array('values' => array('multi1', 'multi2')), 'tagCloud' => array('values' => array('tag1', 'tag2')));
     $this->assertEquals($compareData, $sanitizedData);
 }
Пример #5
0
 /**
  * Sanitizes data for date and date time attributes by converting them to the proper
  * format and timezone for saving.
  * @return - array sanitized data
  */
 public static function sanitizeDataByDesignerTypeForSavingModel($model, $data)
 {
     assert('$model instanceof RedBeanModel || $model instanceof ModelForm');
     assert('is_array($data)');
     foreach ($data as $attributeName => $value) {
         if ($value !== null && static::isNotMarkedSkipped($attributeName)) {
             if (!is_array($value)) {
                 if ($model->isAttribute($attributeName) && $model->isAttributeSafe($attributeName)) {
                     $designerType = ModelAttributeToDesignerTypeUtil::getDesignerType($model, $attributeName);
                     if ($designerType == 'Date' && !empty($value)) {
                         $data[$attributeName] = DateTimeUtil::resolveValueForDateDBFormatted($value);
                     }
                     if ($designerType == 'DateTime' && !empty($value)) {
                         $data[$attributeName] = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero($value);
                     }
                     $data[$attributeName] = static::purifyHtml($data[$attributeName]);
                 }
             } else {
                 try {
                     $designerType = ModelAttributeToDesignerTypeUtil::getDesignerType($model, $attributeName);
                 } catch (NotImplementedException $e) {
                     //In the event that a designer type does not exist.
                     $designerType = null;
                 }
                 if ($model->isAttributeSafe($attributeName) && $designerType != 'TagCloud') {
                     if ($designerType == 'MixedDateTypesForSearch' && isset($value['firstDate']) && $value['firstDate'] != null) {
                         $data[$attributeName]['firstDate'] = DateTimeUtil::resolveValueForDateDBFormatted($value['firstDate']);
                     }
                     if ($designerType == 'MixedDateTypesForSearch' && isset($value['secondDate']) && $value['secondDate'] != null) {
                         $data[$attributeName]['secondDate'] = DateTimeUtil::resolveValueForDateDBFormatted($value['secondDate']);
                     }
                 } elseif (isset($value['values']) && is_string($value['values']) && $designerType == 'TagCloud') {
                     if ($data[$attributeName]['values'] == '') {
                         $data[$attributeName]['values'] = array();
                     } else {
                         $data[$attributeName]['values'] = explode(',', $data[$attributeName]['values']);
                         // Not Coding Standard
                     }
                 }
                 if ($designerType == 'CheckBox') {
                     $data[$attributeName] = $value['value'];
                 } else {
                     array_walk_recursive($data[$attributeName], array(get_called_class(), 'purifyHtmlAndModifyInput'));
                 }
             }
         }
     }
     return $data;
 }
Пример #6
0
 /**
  * @param string $modelClassName
  * @param array $actionData
  * @param string $workflowType
  * @return array
  */
 public static function sanitizeActionData($modelClassName, $actionData, $workflowType)
 {
     assert('is_string($modelClassName)');
     assert('is_array($actionData)');
     assert('is_string($workflowType)');
     if (!isset($actionData[ActionForWorkflowForm::ACTION_ATTRIBUTES])) {
         return $actionData;
     }
     $actionForSanitizing = new ActionForWorkflowForm($modelClassName, $workflowType);
     $actionForSanitizing->setAttributes($actionData);
     foreach ($actionData[ActionForWorkflowForm::ACTION_ATTRIBUTES] as $attribute => $attributeData) {
         if (isset($attributeData['value'])) {
             $type = $actionForSanitizing->getActionAttributesAttributeFormType($attribute);
             if ($type == 'Date' && $attributeData['type'] == DateWorkflowActionAttributeForm::TYPE_STATIC) {
                 $actionData[ActionForWorkflowForm::ACTION_ATTRIBUTES][$attribute]['value'] = DateTimeUtil::resolveValueForDateDBFormatted($attributeData['value']);
             } elseif ($type == 'DateTime' && $attributeData['type'] == DateTimeWorkflowActionAttributeForm::TYPE_STATIC) {
                 $actionData[ActionForWorkflowForm::ACTION_ATTRIBUTES][$attribute]['value'] = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero($attributeData['value']);
             }
         }
     }
     return $actionData;
 }
Пример #7
0
 public function testConvertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero()
 {
     $timeZone = date_default_timezone_get();
     date_default_timezone_set('GMT');
     $dbValue = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('6/3/80 12:00 AM');
     $this->assertEquals('1980-06-03 00:00:00', $dbValue);
     //other locales
     Yii::app()->setLanguage('de');
     $displayValue = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('03.06.80 00:00');
     $this->assertEquals('1980-06-03 00:00:00', $displayValue);
     Yii::app()->setLanguage('it');
     $displayValue = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('03/06/80 00:00');
     $this->assertEquals('1980-06-03 00:00:00', $displayValue);
     Yii::app()->setLanguage('fr');
     $displayValue = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('03/06/80 00:00');
     $this->assertEquals('1980-06-03 00:00:00', $displayValue);
     //test null value returns null.
     $displayValue = DateTimeUtil::convertDbFormattedDateTimeToLocaleFormattedDisplay(null);
     $this->assertEquals(null, $displayValue);
     date_default_timezone_set($timeZone);
 }
Пример #8
0
 /**
  * @depends testResolveUpdateActionWithDynamicValues
  */
 public function testResolveUpdateRelatedActionWithStaticValues()
 {
     $contactStates = ContactState::getAll();
     $this->assertTrue($contactStates[0]->id > 0);
     $contactState = $contactStates[0];
     $currency = Currency::getByCode('USD');
     $bobby = User::getByUsername('bobby');
     $workflow = new Workflow();
     $workflow->setType(Workflow::TYPE_ON_SAVE);
     $workflow->setModuleClassName('WorkflowsTest2Module');
     $data = array();
     $data[ComponentForWorkflowForm::TYPE_ACTIONS][0]['type'] = ActionForWorkflowForm::TYPE_UPDATE_RELATED;
     $data[ComponentForWorkflowForm::TYPE_ACTIONS][0]['relation'] = 'hasMany2';
     $data[ComponentForWorkflowForm::TYPE_ACTIONS][0][ActionForWorkflowForm::ACTION_ATTRIBUTES] = array('boolean' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '1'), 'boolean2' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '0'), 'currencyValue' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '362.24', 'currencyId' => $currency->id), 'date' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '2/24/2012'), 'dateTime' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '2/24/2012 03:00 AM'), 'dropDown' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'Value 1'), 'float' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '54.25'), 'integer' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '32'), 'likeContactState' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => $contactState->id), 'multiDropDown' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => array('Multi Value 1', 'Multi Value 2')), 'owner' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => $bobby->id), 'phone' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '8471112222'), 'primaryAddress___street1' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '123 Main Street'), 'primaryEmail___emailAddress' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => '*****@*****.**'), 'radioDropDown' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'Radio Value 1'), 'string' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'jason'), 'tagCloud' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => array('Tag Value 1', 'Tag Value 2')), 'textArea' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'some description'), 'url' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'http://www.zurmo.com'));
     DataToWorkflowUtil::resolveActions($data, $workflow);
     $actions = $workflow->getActions();
     $this->assertCount(1, $actions);
     $this->assertEquals(ActionForWorkflowForm::TYPE_UPDATE_RELATED, $actions[0]->type);
     $this->assertEquals('hasMany2', $actions[0]->relation);
     $this->assertEquals(ActionForWorkflowForm::RELATION_FILTER_ALL, $actions[0]->relationFilter);
     $this->assertEquals(19, $actions[0]->getActionAttributeFormsCount());
     $this->assertTrue($actions[0]->getActionAttributeFormByName('boolean') instanceof CheckBoxWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('boolean')->type);
     $this->assertEquals('1', $actions[0]->getActionAttributeFormByName('boolean')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('boolean2') instanceof CheckBoxWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('boolean2')->type);
     $this->assertEquals('0', $actions[0]->getActionAttributeFormByName('boolean2')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('currencyValue') instanceof CurrencyValueWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('currencyValue')->type);
     $this->assertEquals(362.24, $actions[0]->getActionAttributeFormByName('currencyValue')->value);
     $this->assertEquals($currency->id, $actions[0]->getActionAttributeFormByName('currencyValue')->currencyId);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('currencyValue')->currencyIdType);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('date') instanceof DateWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('date')->type);
     $this->assertEquals('2012-02-24', $actions[0]->getActionAttributeFormByName('date')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('dateTime') instanceof DateTimeWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('dateTime')->type);
     $compareDateTime = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero('2/24/2012 03:00 AM');
     $this->assertEquals($compareDateTime, $actions[0]->getActionAttributeFormByName('dateTime')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('dropDown') instanceof DropDownWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('dropDown')->type);
     $this->assertEquals('Value 1', $actions[0]->getActionAttributeFormByName('dropDown')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('float') instanceof DecimalWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('float')->type);
     $this->assertEquals('54.25', $actions[0]->getActionAttributeFormByName('float')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('integer') instanceof IntegerWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('integer')->type);
     $this->assertEquals('32', $actions[0]->getActionAttributeFormByName('integer')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('likeContactState') instanceof ContactStateWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('likeContactState')->type);
     $this->assertEquals($contactState->id, $actions[0]->getActionAttributeFormByName('likeContactState')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('multiDropDown') instanceof MultiSelectDropDownWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('multiDropDown')->type);
     $this->assertEquals(array('Multi Value 1', 'Multi Value 2'), $actions[0]->getActionAttributeFormByName('multiDropDown')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('owner') instanceof UserWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('owner')->type);
     $this->assertEquals($bobby->id, $actions[0]->getActionAttributeFormByName('owner')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('phone') instanceof PhoneWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('phone')->type);
     $this->assertEquals('8471112222', $actions[0]->getActionAttributeFormByName('phone')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('primaryAddress___street1') instanceof TextWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('primaryAddress___street1')->type);
     $this->assertEquals('123 Main Street', $actions[0]->getActionAttributeFormByName('primaryAddress___street1')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('primaryEmail___emailAddress') instanceof EmailWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('primaryEmail___emailAddress')->type);
     $this->assertEquals('*****@*****.**', $actions[0]->getActionAttributeFormByName('primaryEmail___emailAddress')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('radioDropDown') instanceof RadioDropDownWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('radioDropDown')->type);
     $this->assertEquals('Radio Value 1', $actions[0]->getActionAttributeFormByName('radioDropDown')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('string') instanceof TextWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('string')->type);
     $this->assertEquals('jason', $actions[0]->getActionAttributeFormByName('string')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('tagCloud') instanceof TagCloudWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('tagCloud')->type);
     $this->assertEquals(array('Tag Value 1', 'Tag Value 2'), $actions[0]->getActionAttributeFormByName('tagCloud')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('textArea') instanceof TextAreaWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('textArea')->type);
     $this->assertEquals('some description', $actions[0]->getActionAttributeFormByName('textArea')->value);
     $this->assertTrue($actions[0]->getActionAttributeFormByName('url') instanceof UrlWorkflowActionAttributeForm);
     $this->assertEquals('Static', $actions[0]->getActionAttributeFormByName('url')->type);
     $this->assertEquals('http://www.zurmo.com', $actions[0]->getActionAttributeFormByName('url')->value);
 }
 /**
  * @param $attributeName
  * @param $value
  * @return string
  */
 public static function sanitizeHiddenAttributeValue($attributeName, $value)
 {
     $designerType = ModelAttributeToDesignerTypeUtil::getDesignerType(new Contact(false), $attributeName);
     $sanitizedAttributeValue = $value;
     if ($designerType == 'Date' && !empty($value)) {
         $sanitizedAttributeValue = DateTimeUtil::resolveValueForDateDBFormatted($value);
     }
     if ($designerType == 'DateTime' && !empty($value)) {
         $sanitizedAttributeValue = DateTimeUtil::convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero($value);
     }
     return DataUtil::purifyHtml($sanitizedAttributeValue);
 }