예제 #1
0
 public static function createImportModelTestItem2($name)
 {
     $model = new ImportModelTestItem2();
     $model->name = $name;
     $saved = $model->save();
     assert('$saved');
     return $model;
 }
예제 #2
0
 public static function createImportModelTestItem2($name)
 {
     $freeze = false;
     if (RedBeanDatabase::isFrozen()) {
         RedBeanDatabase::unfreeze();
         $freeze = true;
     }
     $model = new ImportModelTestItem2();
     $model->name = $name;
     $saved = $model->save();
     assert('$saved');
     if ($freeze) {
         RedBeanDatabase::freeze();
     }
     return $model;
 }
예제 #3
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $super = SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = $super;
     $columnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
     RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem::getTableName('Account'), $columnName);
     RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem2::getTableName('Contact'), $columnName);
     RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem3::getTableName('Opportunity'), $columnName);
     $account = AccountTestHelper::createAccountByNameForOwner('testAccount', $super);
     ImportTestHelper::updateModelsExternalId($account, 'ACC');
     $contact = ContactTestHelper::createContactByNameForOwner('testContact', $super);
     ImportTestHelper::updateModelsExternalId($contact, 'CON');
     $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('testOpportunity', $super);
     ImportTestHelper::updateModelsExternalId($opportunity, 'OPP');
 }
 public function testImportNameAndRelatedNameWithApostrophes()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $testModels = ImportModelTestItem::getAll();
     $this->assertEquals(0, count($testModels));
     $import = new Import();
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $serializedData['firstRowIsHeaderRow'] = true;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importApostropheTest.csv', $import->getTempTableName(), true);
     $this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName()));
     // includes header rows.
     $mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('string'), 'column_1' => ImportMappingUtil::makeStringColumnMappingData('lastName'), 'column_2' => array('attributeIndexOrDerivedType' => 'hasOne', 'type' => 'importColumn', 'mappingRulesData' => array('RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::ZURMO_MODEL_NAME))));
     $importRules = ImportRulesUtil::makeImportRulesByType('ImportModelTestItem');
     $page = 0;
     $config = array('pagination' => array('pageSize' => 50));
     //This way all rows are processed.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $dataProvider->getPagination()->setCurrentPage($page);
     $importResultsUtil = new ImportResultsUtil($import);
     $messageLogger = new ImportMessageLogger();
     ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
     $importResultsUtil->processStatusAndMessagesForEachRow();
     //Confirm that 2 ImportModelTestItem models were created and 2 ImportModelTestItem2 were created
     $testModels = ImportModelTestItem::getAll();
     $this->assertEquals(2, count($testModels));
     $this->assertEquals("Barrel'o Fun", $testModels[0]->lastName);
     $this->assertEquals('bLastName', $testModels[1]->lastName);
     $testModels = ImportModelTestItem2::getAll();
     $this->assertEquals(2, count($testModels));
     $this->assertEquals("D'Angelo Inc", $testModels[0]->name);
     $this->assertEquals('Dartmouth Financial Services', $testModels[1]->name);
     //Clear out data in table
     ImportModelTestItem::deleteAll();
 }
예제 #5
0
 public function testSanitizeValueBySanitizerTypesForRelatedModelIdTypeThatNotIsRequired()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $importModelTestItem2Model1 = ImportTestHelper::createImportModelTestItem2('aaa');
     $importModelTestItem2Model2 = ImportTestHelper::createImportModelTestItem2('bbb');
     $importModelTestItem2Model3 = ImportTestHelper::createImportModelTestItem2('ccc');
     //Update the external system id.
     $columnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
     RedBeanColumnTypeOptimizer::externalIdColumn(ImportModelTestItem2::getTableName('ImportModelTestItem2'), $columnName);
     $externalSystemIdColumnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
     R::exec("update " . ImportModelTestItem2::getTableName('ImportModelTestItem2') . " set {$externalSystemIdColumnName} = 'R' where id = {$importModelTestItem2Model3->id}");
     //Test a non-required related model with an invalid value
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::ZURMO_MODEL_ID)));
     $sanitizerUtilTypes = ImportModelTestItem2AttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'ImportModelTestItem', 'hasOne', 'qweqwe', 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertNull($sanitizedValue);
     $this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(1, count($messages));
     $compareMessage = 'Import - Has One Id specified did not match any existing records.';
     $this->assertEquals($compareMessage, $messages[0]);
     //Test a non-required related model with no value.
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::ZURMO_MODEL_ID)));
     $sanitizerUtilTypes = ImportModelTestItem2AttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'ImportModelTestItem', 'hasOne', null, 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertNull($sanitizedValue);
     $this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(0, count($messages));
     //Test a non-required related model with a valid zurmo model id
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::ZURMO_MODEL_ID)));
     $sanitizerUtilTypes = ImportModelTestItem2AttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'ImportModelTestItem', 'hasOne', $importModelTestItem2Model2->id, 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertEquals($importModelTestItem2Model2, $sanitizedValue);
     $this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(0, count($messages));
     //Test a non-required related model with a valid external system id
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::EXTERNAL_SYSTEM_ID)));
     $sanitizerUtilTypes = ImportModelTestItem2AttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'ImportModelTestItem', 'hasOne', 'R', 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertEquals($importModelTestItem2Model3, $sanitizedValue);
     $this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(0, count($messages));
     //Test a non-required related model with a valid model name
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::ZURMO_MODEL_NAME)));
     $sanitizerUtilTypes = ImportModelTestItem2AttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'ImportModelTestItem', 'hasOne', 'bbb', 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertEquals($importModelTestItem2Model2, $sanitizedValue);
     $this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(0, count($messages));
     //Test a non-required related model with a model name for a new model.
     $importSanitizeResultsUtil = new ImportSanitizeResultsUtil();
     $columnMappingData = array('type' => 'importColumn', 'mappingRulesData' => array('RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::ZURMO_MODEL_NAME)));
     $sanitizerUtilTypes = ImportModelTestItem2AttributeImportRules::getSanitizerUtilTypesInProcessingOrder();
     $sanitizedValue = ImportSanitizerUtil::sanitizeValueBySanitizerTypes($sanitizerUtilTypes, 'ImportModelTestItem', 'hasOne', 'rrr', 'column_0', $columnMappingData, $importSanitizeResultsUtil);
     $this->assertEquals('rrr', $sanitizedValue->name);
     $this->assertEquals('ImportModelTestItem2', get_class($sanitizedValue));
     $this->assertTrue($importSanitizeResultsUtil->shouldSaveModel());
     $messages = $importSanitizeResultsUtil->getMessages();
     $this->assertEquals(0, count($messages));
 }
예제 #6
0
 /**
  * @depends testImportDataAnalysisResultsForMultiSelectMissingMappingRuleForm
  */
 public function testImportDataAnalysisResults()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $import = new Import();
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName());
     R::exec("update " . $import->getTempTableName() . " set column_8 = " . Yii::app()->user->userModel->id . " where id != 1 limit 4");
     $externalSystemIdColumnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
     //Add test ImportModelTestItem models for use in this test.
     $importModelTestItemModel1 = ImportTestHelper::createImportModelTestItem('aaa', 'aba');
     $importModelTestItemModel2 = ImportTestHelper::createImportModelTestItem('ddw', 'daf');
     //Update for of the import rows to point to model 1.  This is for the ZURMO_MODEL_ID mapping rule form type value.
     R::exec("update " . $import->getTempTableName() . " set column_10 = " . $importModelTestItemModel1->id . " where id != 1 limit 3");
     //Update model2 to have an externalSystemId.
     R::exec("update " . ImportModelTestItem::getTableName('ImportModelTestItem') . " set {$externalSystemIdColumnName} = 'B' where id = {$importModelTestItemModel2->id}");
     //Add test ImportModelTestItem2 models for use in this test.
     $importModelTestItem2Model1 = ImportTestHelper::createImportModelTestItem2('aaa');
     $importModelTestItem2Model2 = ImportTestHelper::createImportModelTestItem2('bbb');
     $importModelTestItem2Model3 = ImportTestHelper::createImportModelTestItem2('ccc');
     //Update for of the import rows to point to model 1.  This is for the ZURMO_MODEL_ID mapping.
     R::exec("update " . $import->getTempTableName() . " set column_14 = " . $importModelTestItem2Model1->id . " where id != 1 limit 4");
     //Update model2 to have an externalSystemId.
     R::exec("update " . ImportModelTestItem2::getTableName('ImportModelTestItem2') . " set {$externalSystemIdColumnName} = 'B' where id = {$importModelTestItem2Model2->id}");
     //Add test ImportModelTestItem3 models for use in this test.
     $importModelTestItem3Model1 = ImportTestHelper::createImportModelTestItem3('aaa');
     $importModelTestItem3Model2 = ImportTestHelper::createImportModelTestItem3('dd');
     //Update for of the import rows to point to model 1.  This is for the ZURMO_MODEL_ID mapping rule form type value.
     R::exec("update " . $import->getTempTableName() . " set column_17 = " . $importModelTestItem3Model1->id . " where id != 1 limit 3");
     //Update model2 to have an externalSystemId.
     R::exec("update " . ImportModelTestItem3::getTableName('ImportModelTestItem3') . " set {$externalSystemIdColumnName} = 'K' where id = {$importModelTestItem3Model2->id}");
     //Add test ImportModelTestItem4 models for use in this test.
     $importModelTestItem4Model1 = ImportTestHelper::createImportModelTestItem4('aaa');
     $importModelTestItem4Model2 = ImportTestHelper::createImportModelTestItem4('dd');
     //Update for of the import rows to point to model 1.  This is for the ZURMO_MODEL_ID mapping rule form type value.
     R::exec("update " . $import->getTempTableName() . " set column_12 = " . $importModelTestItem4Model1->id . " where id != 1 limit 5");
     //Update model2 to have an externalSystemId.
     R::exec("update " . ImportModelTestItem3::getTableName('ImportModelTestItem4') . " set {$externalSystemIdColumnName} = 'J' where id = {$importModelTestItem4Model2->id}");
     $mappingData = array('column_0' => array('attributeIndexOrDerivedType' => 'string', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_1' => array('attributeIndexOrDerivedType' => 'phone', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_2' => array('attributeIndexOrDerivedType' => 'float', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_3' => array('attributeIndexOrDerivedType' => 'boolean', 'type' => 'importColumn'), 'column_4' => array('attributeIndexOrDerivedType' => 'date', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null), 'ValueFormatMappingRuleForm' => array('format' => 'MM-dd-yyyy'))), 'column_5' => array('attributeIndexOrDerivedType' => 'dateTime', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null), 'ValueFormatMappingRuleForm' => array('format' => 'MM-dd-yyyy hh:mm'))), 'column_6' => array('attributeIndexOrDerivedType' => 'dropDown', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueDropDownModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_7' => array('attributeIndexOrDerivedType' => 'createdByUser', 'type' => 'importColumn', 'mappingRulesData' => array('UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::ZURMO_USERNAME))), 'column_8' => array('attributeIndexOrDerivedType' => 'modifiedByUser', 'type' => 'importColumn', 'mappingRulesData' => array('UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::ZURMO_USER_ID))), 'column_9' => array('attributeIndexOrDerivedType' => 'owner', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => null), 'UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::EXTERNAL_SYSTEM_USER_ID))), 'column_10' => array('attributeIndexOrDerivedType' => 'id', 'type' => 'importColumn', 'mappingRulesData' => array('IdValueTypeMappingRuleForm' => array('type' => IdValueTypeMappingRuleForm::ZURMO_MODEL_ID))), 'column_11' => array('attributeIndexOrDerivedType' => 'id', 'type' => 'importColumn', 'mappingRulesData' => array('IdValueTypeMappingRuleForm' => array('type' => IdValueTypeMappingRuleForm::EXTERNAL_SYSTEM_ID))), 'column_12' => array('attributeIndexOrDerivedType' => 'hasOneAlso', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => null), 'IdValueTypeMappingRuleForm' => array('type' => IdValueTypeMappingRuleForm::ZURMO_MODEL_ID))), 'column_13' => array('attributeIndexOrDerivedType' => 'hasOneAlso', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => null), 'IdValueTypeMappingRuleForm' => array('type' => IdValueTypeMappingRuleForm::EXTERNAL_SYSTEM_ID))), 'column_14' => array('attributeIndexOrDerivedType' => 'hasOne', 'type' => 'importColumn', 'mappingRulesData' => array('RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::ZURMO_MODEL_ID))), 'column_15' => array('attributeIndexOrDerivedType' => 'hasOne', 'type' => 'importColumn', 'mappingRulesData' => array('RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::EXTERNAL_SYSTEM_ID))), 'column_16' => array('attributeIndexOrDerivedType' => 'hasOne', 'type' => 'importColumn', 'mappingRulesData' => array('RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::ZURMO_MODEL_NAME))), 'column_17' => array('attributeIndexOrDerivedType' => 'ImportModelTestItem3Derived', 'type' => 'importColumn', 'mappingRulesData' => array('IdValueTypeMappingRuleForm' => array('type' => IdValueTypeMappingRuleForm::ZURMO_MODEL_ID))), 'column_18' => array('attributeIndexOrDerivedType' => 'ImportModelTestItem3Derived', 'type' => 'importColumn', 'mappingRulesData' => array('IdValueTypeMappingRuleForm' => array('type' => IdValueTypeMappingRuleForm::EXTERNAL_SYSTEM_ID))), 'column_19' => array('attributeIndexOrDerivedType' => 'url', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_20' => array('attributeIndexOrDerivedType' => 'textArea', 'type' => 'importColumn'), 'column_21' => array('attributeIndexOrDerivedType' => 'integer', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_22' => array('attributeIndexOrDerivedType' => 'currencyValue', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_23' => array('attributeIndexOrDerivedType' => 'FullName', 'type' => 'importColumn', 'mappingRulesData' => array('FullNameDefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_24' => array('attributeIndexOrDerivedType' => 'multiDropDown', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueMultiSelectDropDownModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_25' => array('attributeIndexOrDerivedType' => 'tagCloud', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueMultiSelectDropDownModelAttributeMappingRuleForm' => array('defaultValue' => null))));
     $serializedData = unserialize($import->serializedData);
     $serializedData['mappingData'] = $mappingData;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     $importRules = ImportRulesUtil::makeImportRulesByType('ImportModelTestItem');
     $config = array('pagination' => array('pageSize' => 2));
     //This test csv has a header row.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     //Run data analyzer
     $importDataAnalyzer = new ImportDataAnalyzer($importRules, $dataProvider);
     foreach ($mappingData as $columnName => $columnMappingData) {
         $importDataAnalyzer->analyzeByColumnNameAndColumnMappingData($columnName, $columnMappingData);
     }
     $messagesData = $importDataAnalyzer->getMessagesData();
     $compareData = array('column_0' => array(array('message' => '1 value(s) are too short for this field. These rows will be skipped during import.', 'sanitizerUtilType' => 'MinimumLength', 'moreAvailable' => false), array('message' => '1 value(s) are too large for this field. These values will be truncated to a length of 64 upon import.', 'sanitizerUtilType' => 'Truncate', 'moreAvailable' => false), array('message' => '1 value(s) are missing and are required. These rows will be skipped on import.', 'sanitizerUtilType' => 'Required', 'moreAvailable' => false)), 'column_1' => array(array('message' => '2 value(s) are too large for this field. These values will be truncated to a length of 14 upon import.', 'sanitizerUtilType' => 'Truncate', 'moreAvailable' => false)), 'column_2' => array(array('message' => '2 value(s) are invalid. These rows will be skipped during import.', 'sanitizerUtilType' => 'Number', 'moreAvailable' => false)), 'column_3' => array(array('message' => '2 value(s) have invalid check box values. These values will be set to false upon import.', 'sanitizerUtilType' => 'Boolean', 'moreAvailable' => false)), 'column_4' => array(array('message' => '2 value(s) have invalid date formats. These values will be cleared during import.', 'sanitizerUtilType' => 'Date', 'moreAvailable' => false)), 'column_5' => array(array('message' => '2 value(s) have invalid date time formats. These values will be cleared during import.', 'sanitizerUtilType' => 'DateTime', 'moreAvailable' => false)), 'column_6' => array(array('message' => '2 dropdown value(s) are missing from the field. These values will be added upon import.', 'sanitizerUtilType' => 'DropDown', 'moreAvailable' => false)), 'column_7' => array(array('message' => '2 username(s) specified were not found. These values will not be used during the import.', 'sanitizerUtilType' => 'UserValueType', 'moreAvailable' => false)), 'column_8' => array(array('message' => '1 zurmo user id(s) across 7 row(s) were not found. These values will not be used during the import.', 'sanitizerUtilType' => 'UserValueType', 'moreAvailable' => false)), 'column_9' => array(array('message' => '2 external system user id(s) specified were not found. These values will not be used during the import.', 'sanitizerUtilType' => 'UserValueType', 'moreAvailable' => false), array('message' => '1 value(s) are missing and are required. These rows will be skipped on import.', 'sanitizerUtilType' => 'ModelIdRequired', 'moreAvailable' => false)), 'column_10' => array(array('message' => '3 record(s) will be updated and 9 record(s) will be skipped during import.', 'sanitizerUtilType' => 'SelfIdValueType', 'moreAvailable' => false)), 'column_11' => array(array('message' => '1 record(s) will be updated and 11 record(s) will be created during the import.', 'sanitizerUtilType' => 'SelfIdValueType', 'moreAvailable' => false)), 'column_12' => array(array('message' => '5 record(s) will be updated and 7 record(s) will be skipped during import.', 'sanitizerUtilType' => 'ModelIdValueType', 'moreAvailable' => false)), 'column_13' => array(array('message' => '2 record(s) will be updated and 10 record(s) will be skipped during import.', 'sanitizerUtilType' => 'ModelIdValueType', 'moreAvailable' => false)), 'column_14' => array(array('message' => '4 record(s) will be updated and 8 record(s) will be skipped during import.', 'sanitizerUtilType' => 'RelatedModelNameOrIdValueType', 'moreAvailable' => false)), 'column_15' => array(array('message' => '1 record(s) will be updated and 11 record(s) will be skipped during import.', 'sanitizerUtilType' => 'RelatedModelNameOrIdValueType', 'moreAvailable' => false)), 'column_16' => array(array('message' => '1 record(s) will be updated and 11 record(s) will be created during the import.', 'sanitizerUtilType' => 'RelatedModelNameOrIdValueType', 'moreAvailable' => false)), 'column_17' => array(array('message' => '3 record(s) will be updated and 9 record(s) will be skipped during import.', 'sanitizerUtilType' => 'ImportModelTestItem3DerivedIdValueType', 'moreAvailable' => false)), 'column_18' => array(array('message' => '2 record(s) will be updated and 10 record(s) will be skipped during import.', 'sanitizerUtilType' => 'ImportModelTestItem3DerivedIdValueType', 'moreAvailable' => false)), 'column_19' => array(array('message' => '1 value(s) have urls that are invalid. These values will be cleared during import.', 'sanitizerUtilType' => 'Url', 'moreAvailable' => false)), 'column_21' => array(array('message' => '1 value(s) are invalid. These rows will be skipped during import.', 'sanitizerUtilType' => 'Number', 'moreAvailable' => false)), 'column_22' => array(array('message' => '1 value(s) are invalid. These rows will be skipped during import.', 'sanitizerUtilType' => 'Number', 'moreAvailable' => false)), 'column_23' => array(array('message' => '1 value(s) are too large for this field. These rows will be skipped during import.', 'sanitizerUtilType' => 'FullName', 'moreAvailable' => false)), 'column_24' => array(array('message' => '2 dropdown value(s) are missing from the field. These values will be added upon import.', 'sanitizerUtilType' => 'MultiSelectDropDown', 'moreAvailable' => false)), 'column_25' => array(array('message' => '2 dropdown value(s) are missing from the field. These values will be added upon import.', 'sanitizerUtilType' => 'MultiSelectDropDown', 'moreAvailable' => false)));
     $this->assertEquals($compareData, $messagesData);
     $importInstructionsData = $importDataAnalyzer->getImportInstructionsData();
     $compareInstructionsData = array('column_6' => array('DropDown' => array(DropDownSanitizerUtil::ADD_MISSING_VALUE => array('neverpresent', 'notpresent'))));
     $compareInstructionsData['column_24'] = array('MultiSelectDropDown' => array(DropDownSanitizerUtil::ADD_MISSING_VALUE => array('Multi 5', 'Multi 4')));
     $compareInstructionsData['column_25'] = array('MultiSelectDropDown' => array(DropDownSanitizerUtil::ADD_MISSING_VALUE => array('Cloud 5', 'Cloud 4')));
     $this->assertEquals($compareInstructionsData, $importInstructionsData);
     ImportUtil::setDataAnalyzerMessagesDataToImport($import, $messagesData);
     $compareData = unserialize($import->serializedData);
     $compareData = $compareData['dataAnalyzerMessagesData'];
     $this->assertEquals($compareData, $messagesData);
     $newMappingData = ImportMappingUtil::resolveImportInstructionsDataIntoMappingData($mappingData, $importInstructionsData);
     $compareMappingData = $mappingData;
     $compareMappingData['column_6']['importInstructionsData'] = $compareInstructionsData['column_6'];
     $compareMappingData['column_24']['importInstructionsData'] = $compareInstructionsData['column_24'];
     $compareMappingData['column_25']['importInstructionsData'] = $compareInstructionsData['column_25'];
     $this->assertEquals($compareMappingData, $newMappingData);
 }
예제 #7
0
 /**
  * @depends testImportDataAnalysisResultsForMultiSelectMissingMappingRuleForm
  */
 public function testImportDataAnalysisResults()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $import = new Import();
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importAnalyzerTest.csv', $import->getTempTableName());
     R::exec("update " . $import->getTempTableName() . " set column_8 = " . Yii::app()->user->userModel->id . " where id != 1 limit 4");
     $externalSystemIdColumnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
     //Add test ImportModelTestItem models for use in this test.
     $importModelTestItemModel1 = ImportTestHelper::createImportModelTestItem('aaa', 'aba');
     $importModelTestItemModel2 = ImportTestHelper::createImportModelTestItem('ddw', 'daf');
     //Update for of the import rows to point to model 1.  This is for the ZURMO_MODEL_ID mapping rule form type value.
     R::exec("update " . $import->getTempTableName() . " set column_10 = " . $importModelTestItemModel1->id . " where id != 1 limit 3");
     //Update model2 to have an externalSystemId.
     R::exec("update " . ImportModelTestItem::getTableName('ImportModelTestItem') . " set {$externalSystemIdColumnName} = 'B' where id = {$importModelTestItemModel2->id}");
     //Add test ImportModelTestItem2 models for use in this test.
     $importModelTestItem2Model1 = ImportTestHelper::createImportModelTestItem2('aaa');
     $importModelTestItem2Model2 = ImportTestHelper::createImportModelTestItem2('bbb');
     $importModelTestItem2Model3 = ImportTestHelper::createImportModelTestItem2('ccc');
     //Update for of the import rows to point to model 1.  This is for the ZURMO_MODEL_ID mapping.
     R::exec("update " . $import->getTempTableName() . " set column_14 = " . $importModelTestItem2Model1->id . " where id != 1 limit 4");
     //Update model2 to have an externalSystemId.
     R::exec("update " . ImportModelTestItem2::getTableName('ImportModelTestItem2') . " set {$externalSystemIdColumnName} = 'B' where id = {$importModelTestItem2Model2->id}");
     //Add test ImportModelTestItem3 models for use in this test.
     $importModelTestItem3Model1 = ImportTestHelper::createImportModelTestItem3('aaa');
     $importModelTestItem3Model2 = ImportTestHelper::createImportModelTestItem3('dd');
     //Update for of the import rows to point to model 1.  This is for the ZURMO_MODEL_ID mapping rule form type value.
     R::exec("update " . $import->getTempTableName() . " set column_17 = " . $importModelTestItem3Model1->id . " where id != 1 limit 3");
     //Update model2 to have an externalSystemId.
     R::exec("update " . ImportModelTestItem3::getTableName('ImportModelTestItem3') . " set {$externalSystemIdColumnName} = 'K' where id = {$importModelTestItem3Model2->id}");
     //Add test ImportModelTestItem4 models for use in this test.
     $importModelTestItem4Model1 = ImportTestHelper::createImportModelTestItem4('aaa');
     $importModelTestItem4Model2 = ImportTestHelper::createImportModelTestItem4('dd');
     //Update for of the import rows to point to model 1.  This is for the ZURMO_MODEL_ID mapping rule form type value.
     R::exec("update " . $import->getTempTableName() . " set column_12 = " . $importModelTestItem4Model1->id . " where id != 1 limit 5");
     //Update model2 to have an externalSystemId.
     R::exec("update " . ImportModelTestItem3::getTableName('ImportModelTestItem4') . " set {$externalSystemIdColumnName} = 'J' where id = {$importModelTestItem4Model2->id}");
     $mappingData = array('column_0' => array('attributeIndexOrDerivedType' => 'string', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_1' => array('attributeIndexOrDerivedType' => 'phone', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_2' => array('attributeIndexOrDerivedType' => 'float', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_3' => array('attributeIndexOrDerivedType' => 'boolean', 'type' => 'importColumn'), 'column_4' => array('attributeIndexOrDerivedType' => 'date', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null), 'ValueFormatMappingRuleForm' => array('format' => 'MM-dd-yyyy'))), 'column_5' => array('attributeIndexOrDerivedType' => 'dateTime', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null), 'ValueFormatMappingRuleForm' => array('format' => 'MM-dd-yyyy hh:mm'))), 'column_6' => array('attributeIndexOrDerivedType' => 'dropDown', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueDropDownModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_7' => array('attributeIndexOrDerivedType' => 'createdByUser', 'type' => 'importColumn', 'mappingRulesData' => array('UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::ZURMO_USERNAME))), 'column_8' => array('attributeIndexOrDerivedType' => 'modifiedByUser', 'type' => 'importColumn', 'mappingRulesData' => array('UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::ZURMO_USER_ID))), 'column_9' => array('attributeIndexOrDerivedType' => 'owner', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => null), 'UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::EXTERNAL_SYSTEM_USER_ID))), 'column_10' => array('attributeIndexOrDerivedType' => 'id', 'type' => 'importColumn', 'mappingRulesData' => array('IdValueTypeMappingRuleForm' => array('type' => IdValueTypeMappingRuleForm::ZURMO_MODEL_ID))), 'column_11' => array('attributeIndexOrDerivedType' => 'id', 'type' => 'importColumn', 'mappingRulesData' => array('IdValueTypeMappingRuleForm' => array('type' => IdValueTypeMappingRuleForm::EXTERNAL_SYSTEM_ID))), 'column_12' => array('attributeIndexOrDerivedType' => 'hasOneAlso', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => null), 'IdValueTypeMappingRuleForm' => array('type' => IdValueTypeMappingRuleForm::ZURMO_MODEL_ID))), 'column_13' => array('attributeIndexOrDerivedType' => 'hasOneAlso', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => null), 'IdValueTypeMappingRuleForm' => array('type' => IdValueTypeMappingRuleForm::EXTERNAL_SYSTEM_ID))), 'column_14' => array('attributeIndexOrDerivedType' => 'hasOne', 'type' => 'importColumn', 'mappingRulesData' => array('RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::ZURMO_MODEL_ID))), 'column_15' => array('attributeIndexOrDerivedType' => 'hasOne', 'type' => 'importColumn', 'mappingRulesData' => array('RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::EXTERNAL_SYSTEM_ID))), 'column_16' => array('attributeIndexOrDerivedType' => 'hasOne', 'type' => 'importColumn', 'mappingRulesData' => array('RelatedModelValueTypeMappingRuleForm' => array('type' => RelatedModelValueTypeMappingRuleForm::ZURMO_MODEL_NAME))), 'column_17' => array('attributeIndexOrDerivedType' => 'ImportModelTestItem3Derived', 'type' => 'importColumn', 'mappingRulesData' => array('IdValueTypeMappingRuleForm' => array('type' => IdValueTypeMappingRuleForm::ZURMO_MODEL_ID))), 'column_18' => array('attributeIndexOrDerivedType' => 'ImportModelTestItem3Derived', 'type' => 'importColumn', 'mappingRulesData' => array('IdValueTypeMappingRuleForm' => array('type' => IdValueTypeMappingRuleForm::EXTERNAL_SYSTEM_ID))), 'column_19' => array('attributeIndexOrDerivedType' => 'url', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_20' => array('attributeIndexOrDerivedType' => 'textArea', 'type' => 'importColumn'), 'column_21' => array('attributeIndexOrDerivedType' => 'integer', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_22' => array('attributeIndexOrDerivedType' => 'currencyValue', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_23' => array('attributeIndexOrDerivedType' => 'FullName', 'type' => 'importColumn', 'mappingRulesData' => array('FullNameDefaultValueModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_24' => array('attributeIndexOrDerivedType' => 'multiDropDown', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueMultiSelectDropDownModelAttributeMappingRuleForm' => array('defaultValue' => null))), 'column_25' => array('attributeIndexOrDerivedType' => 'tagCloud', 'type' => 'importColumn', 'mappingRulesData' => array('DefaultValueMultiSelectDropDownModelAttributeMappingRuleForm' => array('defaultValue' => null))));
     $serializedData = unserialize($import->serializedData);
     $serializedData['mappingData'] = $mappingData;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     $importRules = ImportRulesUtil::makeImportRulesByType('ImportModelTestItem');
     $config = array('pagination' => array('pageSize' => 15));
     //This test csv has a header row.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     //Run data analyzer
     $importDataAnalyzer = new ImportDataAnalyzer($importRules, $dataProvider, $mappingData, array_keys($mappingData));
     $importDataAnalyzer->analyzePage();
     $data = $dataProvider->getData();
     $this->assertEquals(12, count($data));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[0]->analysisStatus);
     $compareData = array();
     $compareData['column_10'] = array('Is an existing record and will be updated.');
     $compareData['column_11'] = array('Was not found and will create a new record during import.');
     $compareData['column_13'] = array('Was not found and this row will be skipped during import.');
     $compareData['column_15'] = array('Was not found and this row will be skipped during import.');
     $compareData['column_16'] = array('Was not found and will create a new record during import.');
     $compareData['column_17'] = array('Is an existing record and will be updated.');
     $compareData['column_18'] = array('Was not found and this row will be skipped during import.');
     $this->assertEquals($compareData, unserialize($data[0]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[0]->analysisStatus);
     $compareData = array();
     $compareData['column_1'] = array('Is too long. Maximum length is 14. This value will truncated upon import.');
     $compareData['column_10'] = array('Is an existing record and will be updated.');
     $compareData['column_11'] = array('Was not found and will create a new record during import.');
     $compareData['column_13'] = array('Was not found and this row will be skipped during import.');
     $compareData['column_15'] = array('Was not found and this row will be skipped during import.');
     $compareData['column_16'] = array('Was not found and will create a new record during import.');
     $compareData['column_17'] = array('Is an existing record and will be updated.');
     $compareData['column_18'] = array('Was not found and this row will be skipped during import.');
     $this->assertEquals($compareData, unserialize($data[1]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[1]->analysisStatus);
     $compareData = array();
     $compareData['column_0'] = array();
     $compareData['column_0'][] = 'Is too long. Maximum length is 64. This value will truncated upon import.';
     $compareData['column_1'] = array();
     $compareData['column_1'][] = 'Is too long. Maximum length is 14. This value will truncated upon import.';
     $compareData['column_10'] = array();
     $compareData['column_10'][] = 'Is an existing record and will be updated.';
     $compareData['column_11'] = array();
     $compareData['column_11'][] = 'Was not found and will create a new record during import.';
     $compareData['column_13'] = array();
     $compareData['column_13'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_15'] = array();
     $compareData['column_15'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_16'] = array();
     $compareData['column_16'][] = 'Was not found and will create a new record during import.';
     $compareData['column_17'] = array();
     $compareData['column_17'][] = 'Is an existing record and will be updated.';
     $compareData['column_18'] = array();
     $compareData['column_18'][] = 'Was not found and this row will be skipped during import.';
     $this->assertEquals($compareData, unserialize($data[2]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[2]->analysisStatus);
     $compareData = array();
     $compareData['column_10'] = array();
     $compareData['column_10'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_11'] = array();
     $compareData['column_11'][] = 'Was not found and will create a new record during import.';
     $compareData['column_13'] = array();
     $compareData['column_13'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_15'] = array();
     $compareData['column_15'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_16'] = array();
     $compareData['column_16'][] = 'Was not found and will create a new record during import.';
     $compareData['column_17'] = array();
     $compareData['column_17'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_18'] = array();
     $compareData['column_18'][] = 'Was not found and this row will be skipped during import.';
     $this->assertEquals($compareData, unserialize($data[3]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[3]->analysisStatus);
     $compareData = array();
     $compareData['column_8'] = array();
     $compareData['column_8'][] = 'Is an invalid user value. This value will be skipped during import.';
     $compareData['column_10'] = array();
     $compareData['column_10'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_11'] = array();
     $compareData['column_11'][] = 'Was not found and will create a new record during import.';
     $compareData['column_13'] = array();
     $compareData['column_13'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_14'] = array();
     $compareData['column_14'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_15'] = array();
     $compareData['column_15'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_16'] = array();
     $compareData['column_16'][] = 'Was not found and will create a new record during import.';
     $compareData['column_17'] = array();
     $compareData['column_17'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_18'] = array();
     $compareData['column_18'][] = 'Was not found and this row will be skipped during import.';
     $this->assertEquals($compareData, unserialize($data[4]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[4]->analysisStatus);
     $compareData = array();
     $compareData['column_2'] = array();
     $compareData['column_2'][] = 'Is invalid.';
     $compareData['column_4'] = array();
     $compareData['column_4'][] = 'Is an invalid date format. This value will be skipped during import.';
     $compareData['column_6'] = array();
     $compareData['column_6'][] = 'notpresent is new. This value will be added upon import.';
     $compareData['column_8'] = array();
     $compareData['column_8'][] = 'Is an invalid user value. This value will be skipped during import.';
     $compareData['column_9'] = array();
     $compareData['column_9'][] = 'Is an invalid user value. This value will be skipped during import.';
     $compareData['column_10'] = array();
     $compareData['column_10'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_11'] = array();
     $compareData['column_11'][] = 'Was not found and will create a new record during import.';
     $compareData['column_12'] = array();
     $compareData['column_12'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_13'] = array();
     $compareData['column_13'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_14'] = array();
     $compareData['column_14'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_15'] = array();
     $compareData['column_15'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_16'] = array();
     $compareData['column_16'][] = 'Was not found and will create a new record during import.';
     $compareData['column_17'] = array();
     $compareData['column_17'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_18'] = array();
     $compareData['column_18'][] = 'Is an existing record and will be updated.';
     $this->assertEquals($compareData, unserialize($data[5]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[5]->analysisStatus);
     $compareData = array();
     $compareData['column_4'] = array();
     $compareData['column_4'][] = 'Is an invalid date format. This value will be skipped during import.';
     $compareData['column_5'] = array();
     $compareData['column_5'][] = 'Is an invalid date time format. This value will be skipped during import.';
     $compareData['column_6'] = array();
     $compareData['column_6'][] = 'neverpresent is new. This value will be added upon import.';
     $compareData['column_8'] = array();
     $compareData['column_8'][] = 'Is an invalid user value. This value will be skipped during import.';
     $compareData['column_10'] = array();
     $compareData['column_10'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_11'] = array();
     $compareData['column_11'][] = 'Was not found and will create a new record during import.';
     $compareData['column_12'] = array();
     $compareData['column_12'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_13'] = array();
     $compareData['column_13'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_14'] = array();
     $compareData['column_14'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_15'] = array();
     $compareData['column_15'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_16'] = array();
     $compareData['column_16'][] = 'Was not found and will create a new record during import.';
     $compareData['column_17'] = array();
     $compareData['column_17'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_18'] = array();
     $compareData['column_18'][] = 'Is an existing record and will be updated.';
     $compareData['column_24'] = array();
     $compareData['column_24'][] = 'Multi 5 is new. This value will be added upon import.';
     $compareData['column_25'] = array();
     $compareData['column_25'][] = 'Cloud 5 is new. This value will be added upon import.';
     $this->assertEquals($compareData, unserialize($data[6]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[6]->analysisStatus);
     $compareData = array();
     $compareData['column_2'] = array();
     $compareData['column_2'][] = 'Is invalid.';
     $compareData['column_7'] = array();
     $compareData['column_7'][] = 'Is an invalid user value. This value will be skipped during import.';
     $compareData['column_8'] = array();
     $compareData['column_8'][] = 'Is an invalid user value. This value will be skipped during import.';
     $compareData['column_9'] = array();
     $compareData['column_9'][] = 'Is an invalid user value. This value will be skipped during import.';
     $compareData['column_10'] = array();
     $compareData['column_10'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_11'] = array();
     $compareData['column_11'][] = 'Was not found and will create a new record during import.';
     $compareData['column_12'] = array();
     $compareData['column_12'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_14'] = array();
     $compareData['column_14'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_15'] = array();
     $compareData['column_15'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_16'] = array();
     $compareData['column_16'][] = 'Was not found and will create a new record during import.';
     $compareData['column_17'] = array();
     $compareData['column_17'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_18'] = array();
     $compareData['column_18'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_21'] = array();
     $compareData['column_21'][] = 'Is invalid.';
     $compareData['column_22'] = array();
     $compareData['column_22'][] = 'Is invalid.';
     $compareData['column_24'] = array();
     $compareData['column_24'][] = 'Multi 4 is new. This value will be added upon import.';
     $compareData['column_25'] = array();
     $compareData['column_25'][] = 'Cloud 4 is new. This value will be added upon import.';
     $this->assertEquals($compareData, unserialize($data[7]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[7]->analysisStatus);
     $compareData = array();
     $compareData['column_3'] = array();
     $compareData['column_3'][] = 'Is an invalid check box value. This will be set to false upon import.';
     $compareData['column_5'] = array();
     $compareData['column_5'][] = 'Is an invalid date time format. This value will be skipped during import.';
     $compareData['column_8'] = array();
     $compareData['column_8'][] = 'Is an invalid user value. This value will be skipped during import.';
     $compareData['column_10'] = array();
     $compareData['column_10'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_11'] = array();
     $compareData['column_11'][] = 'Is an existing record and will be updated.';
     $compareData['column_12'] = array();
     $compareData['column_12'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_14'] = array();
     $compareData['column_14'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_15'] = array();
     $compareData['column_15'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_16'] = array();
     $compareData['column_16'][] = 'Was not found and will create a new record during import.';
     $compareData['column_17'] = array();
     $compareData['column_17'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_18'] = array();
     $compareData['column_18'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_21'] = array();
     $compareData['column_21'][] = 'Is invalid.';
     $compareData['column_24'] = array();
     $compareData['column_24'][] = 'Multi 4 is new. This value will be added upon import.';
     $compareData['column_24'][] = 'Multi 5 is new. This value will be added upon import.';
     $compareData['column_25'] = array();
     $compareData['column_25'][] = 'Cloud 4 is new. This value will be added upon import.';
     $compareData['column_25'][] = 'Cloud 5 is new. This value will be added upon import.';
     $this->assertEquals($compareData, unserialize($data[8]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[8]->analysisStatus);
     $compareData = array();
     $compareData['column_8'] = array();
     $compareData['column_8'][] = 'Is an invalid user value. This value will be skipped during import.';
     $compareData['column_10'] = array();
     $compareData['column_10'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_11'] = array();
     $compareData['column_11'][] = 'Was not found and will create a new record during import.';
     $compareData['column_12'] = array();
     $compareData['column_12'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_13'] = array();
     $compareData['column_13'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_14'] = array();
     $compareData['column_14'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_15'] = array();
     $compareData['column_15'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_16'] = array();
     $compareData['column_16'][] = 'Is an existing record and will be linked.';
     $compareData['column_17'] = array();
     $compareData['column_17'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_18'] = array();
     $compareData['column_18'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_19'] = array();
     $compareData['column_19'][] = 'Is an invalid URL. This value will be cleared during import.';
     $compareData['column_23'] = array();
     $compareData['column_23'][] = 'Is too long.';
     $this->assertEquals($compareData, unserialize($data[9]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[9]->analysisStatus);
     $compareData = array();
     $compareData['column_3'] = array();
     $compareData['column_3'][] = 'Is an invalid check box value. This will be set to false upon import.';
     $compareData['column_7'] = array();
     $compareData['column_7'][] = 'Is an invalid user value. This value will be skipped during import.';
     $compareData['column_8'] = array();
     $compareData['column_8'][] = 'Is an invalid user value. This value will be skipped during import.';
     $compareData['column_10'] = array();
     $compareData['column_10'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_11'] = array();
     $compareData['column_11'][] = 'Was not found and will create a new record during import.';
     $compareData['column_12'] = array();
     $compareData['column_12'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_13'] = array();
     $compareData['column_13'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_14'] = array();
     $compareData['column_14'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_16'] = array();
     $compareData['column_16'][] = 'Was not found and will create a new record during import.';
     $compareData['column_17'] = array();
     $compareData['column_17'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_18'] = array();
     $compareData['column_18'][] = 'Was not found and this row will be skipped during import.';
     $this->assertEquals($compareData, unserialize($data[10]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[10]->analysisStatus);
     $compareData = array();
     $compareData['column_0'] = array();
     $compareData['column_0'][] = 'Is  required.';
     $compareData['column_9'] = array();
     $compareData['column_9'][] = 'Is  required.';
     $compareData['column_10'] = array();
     $compareData['column_10'][] = 'Was not found and this row will be skipped during import.';
     $compareData['column_11'] = array();
     $compareData['column_11'][] = 'Was not found and will create a new record during import.';
     $this->assertEquals($compareData, unserialize($data[11]->serializedAnalysisMessages));
     $this->assertEquals(ImportDataAnalyzer::STATUS_SKIP, $data[11]->analysisStatus);
     $customFieldsInstructionData = $importDataAnalyzer->getCustomFieldsInstructionData();
     $this->assertTrue($customFieldsInstructionData->hasDataByColumnName('column_6'));
     $compareData = array(CustomFieldsInstructionData::ADD_MISSING_VALUES => array('notpresent', 'neverpresent'));
     $this->assertEquals($compareData, $customFieldsInstructionData->getDataByColumnName('column_6'));
     $compareData = array(CustomFieldsInstructionData::ADD_MISSING_VALUES => array('Multi 5', 'Multi 4'));
     $this->assertEquals($compareData, $customFieldsInstructionData->getDataByColumnName('column_24'));
     $compareData = array(CustomFieldsInstructionData::ADD_MISSING_VALUES => array('Cloud 5', 'Cloud 4'));
     $this->assertEquals($compareData, $customFieldsInstructionData->getDataByColumnName('column_25'));
 }