/**
  * Step 1. Select the module to import data into.
  */
 public function actionStep1()
 {
     $importWizardForm = new ImportWizardForm();
     if (isset($_GET['id'])) {
         $import = Import::getById((int) $_GET['id']);
     } else {
         $import = new Import();
     }
     $importWizardForm = ImportWizardUtil::makeFormByImport($import);
     if (isset($_POST[get_class($importWizardForm)])) {
         ImportWizardUtil::setFormByPostForStep1($importWizardForm, $_POST[get_class($importWizardForm)]);
         $this->attemptToValidateImportWizardFormAndSave($importWizardForm, $import, 'step2');
     }
     $title = Zurmo::t('ImportModule', 'Import Wizard: Step 1 of 6');
     $importView = new ImportWizardImportRulesView($this->getId(), $this->getModule()->getId(), $importWizardForm, $title);
     $view = new ImportPageView(ZurmoDefaultAdminViewUtil::makeStandardViewForCurrentUser($this, $importView));
     echo $view->render();
 }
 /**
  * Step 1. Select the module to import data into.
  */
 public function actionStep1()
 {
     $importWizardForm = new ImportWizardForm();
     if (isset($_GET['id'])) {
         $import = Import::getById((int) $_GET['id']);
     } else {
         $import = new Import();
     }
     $importWizardForm = ImportWizardUtil::makeFormByImport($import);
     if (isset($_POST[get_class($importWizardForm)])) {
         ImportWizardUtil::setFormByPostForStep1($importWizardForm, $_POST[get_class($importWizardForm)]);
         $this->attemptToValidateImportWizardFormAndSave($importWizardForm, $import, 'step2');
     }
     $title = Zurmo::t('ImportModule', 'Import Wizard - Select Module');
     if ($importWizardForm->importRulesType != null) {
         $importRulesClassName = ImportRulesUtil::getImportRulesClassNameByType($importWizardForm->importRulesType);
     } else {
         $importRulesClassName = null;
     }
     $progressBarAndStepsView = new ImportStepsAndProgressBarForWizardView($importRulesClassName, 0);
     $importView = new ImportWizardImportRulesView($this->getId(), $this->getModule()->getId(), $importWizardForm, $title);
     echo $this->getImportPageView($progressBarAndStepsView, $importView)->render();
 }
 /**
  * @depends testSetImportSerializedDataFromForm
  */
 public function testSetFormByPostForStep1()
 {
     //Test without an existing value for importRulesType
     $fakePostData = array('importRulesType' => 'xyz');
     $importWizardForm = new ImportWizardForm();
     $this->assertEquals(null, $importWizardForm->importRulesType);
     $this->assertEquals(null, $importWizardForm->fileUploadData);
     $importWizardForm->fileUploadData = 'something';
     ImportWizardUtil::setFormByPostForStep1($importWizardForm, $fakePostData);
     $this->assertEquals('xyz', $importWizardForm->importRulesType);
     $this->assertEquals(null, $importWizardForm->fileUploadData);
     //Test with an existing value for importRulesType but it is the same value we are populating it with
     $importWizardForm->fileUploadData = 'abc';
     ImportWizardUtil::setFormByPostForStep1($importWizardForm, $fakePostData);
     $this->assertEquals('xyz', $importWizardForm->importRulesType);
     $this->assertEquals('abc', $importWizardForm->fileUploadData);
     //Test with an existing value for importRulesType and we are changing it.
     $fakePostData = array('importRulesType' => 'def');
     ImportWizardUtil::setFormByPostForStep1($importWizardForm, $fakePostData);
     $this->assertEquals('def', $importWizardForm->importRulesType);
     $this->assertEquals(null, $importWizardForm->fileUploadData);
 }