Skip to content

Commit

Permalink
DEV: add viewTests that require activated survey (travis) (#992)
Browse files Browse the repository at this point in the history
* DEV: activate some viewtests

* DEV: activate some viewtests

* DEV: add view tests for activated surveys

* DEV: add view tests for activated surveys

* DEV: add view tests for activated surveys - add tokens table

* DEV: add view tests for activated surveys - clean up properly
  • Loading branch information
TonisOrmisson committed Feb 4, 2018
1 parent 5b936cb commit 4aea797
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 24 deletions.
2 changes: 1 addition & 1 deletion application/models/Survey.php
Expand Up @@ -200,7 +200,7 @@ public function attributeLabels()
/** @inheritdoc */
public function delete()
{
return $this->deleteSurvey($this->sid);
return $this->deleteSurvey($this->sid,true);
}


Expand Down
Expand Up @@ -5,6 +5,9 @@

$gid = isset($gid) ? $gid : NULL;
$qid = isset($qid) ? $qid : NULL;

// DO NOT REMOVE This is for automated testing to validate we see that page
echo viewHelper::getViewTestTag('surveyLogicFile');
?>

<div id='edit-survey-text-element' class='side-body <?php echo getSideBodyClass(false); ?>'>
Expand Down
4 changes: 2 additions & 2 deletions tests/TestBaseClass.php
Expand Up @@ -54,7 +54,7 @@ protected static function importSurvey($fileName)
\Yii::app()->session['loginID'] = 1;
$surveyFile = $fileName;
if (!file_exists($surveyFile)) {
self::assertTrue(false, 'Found no survey file ' . $fileName);
throw new \Exception(sprintf('Survey file %s not found',$surveyFile));
}

$translateLinksFields = false;
Expand All @@ -69,7 +69,7 @@ protected static function importSurvey($fileName)
self::$testSurvey = \Survey::model()->findByPk($result['newsid']);
self::$surveyId = $result['newsid'];
} else {
self::assertTrue(false, 'Could not import survey file ' . $fileName);
throw new \Exception(sprintf('Failed to import survey file %s',$surveyFile));
}
}

Expand Down
8 changes: 6 additions & 2 deletions tests/controllers/AdminViewsTest.php
Expand Up @@ -77,22 +77,26 @@ public function testAdminViews($name, $view)
public function testAdminSurveyViews($name, $view)
{
if (isset($view['import_id'])) {

// we'll change the survey in the middle of test
if(self::$testSurvey){
self::$testSurvey->delete();
}
$surveyFile = self::$surveysFolder . '/limesurvey_survey_'.$view['import_id'].'.lss';
self::importSurvey($surveyFile);

if(isset($view['activate']) && $view['activate'] ){
$activator = new \SurveyActivator(self::$testSurvey);
$activator->activate();
\Token::createTable(self::$surveyId);
}

} elseif (empty(self::$surveyId)) {
// This situation can happen if we test only one data entry,
// using --filter="testAdminSurveyViews#13" (for data entry 13).
$surveyFile = self::$surveysFolder . '/../data/surveys/limesurvey_survey_454287.lss';
self::importSurvey($surveyFile);

}

$view['route'] = ReplaceFields($view['route'], ['{SID}'=> self::$testSurvey->primaryKey]);
$this->findViewTag($name, $view);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/controllers/CreateSurveyTest.php
Expand Up @@ -54,7 +54,7 @@ public static function teardownAfterClass()
$criteria->with = ['correct_relation_defaultlanguage'];
$survey = \Survey::model()->find($criteria);
if ($survey) {
$survey->deleteSurvey($survey->sid);
$survey->deleteSurvey($survey->sid,true);
}
}

Expand Down
33 changes: 15 additions & 18 deletions tests/data/views/adminSurveyViews.php
Expand Up @@ -19,8 +19,6 @@
['surveyTemplateOptionsUpdate', ['route'=>'themeoptions/sa/updatesurvey/surveyid/{SID}/gsid/1']],
['surveyPresentationOptions', ['route'=>'survey/sa/rendersidemenulink/subaction/presentation/surveyid/{SID}']],

// FIXME these FAIL !!
//['surveyParticipantsIndex', ['route'=>'tokens/sa/index/surveyid/{SID}']],

['surveyResources', ['route'=>'survey/sa/rendersidemenulink/subaction/resources/surveyid/{SID}']],
['surveyPermissions', ['route'=>'surveypermission/sa/view/surveyid/{SID}']],
Expand All @@ -38,28 +36,27 @@
// going deeper -------------------------------------
// --------------------------------------------------

//['surveyLogicFile', ['route'=>'expressions/sa/survey_logic_file/sid/{SID}']], // TODO
// adding elements to survey
['addQuestion', ['route'=>'questions/sa/newquestion/surveyid/{SID}']],
['addQuestionGroup', ['route'=>'questiongroups/sa/add/surveyid/{SID}']],
['importQuestionGroup', ['route'=>'questiongroups/sa/importview/surveyid/{SID}']],
['addQuota', ['route'=>'quotas/sa/newquota/surveyid/{SID}']],

['surveyLogicFile', ['route'=>'expressions/sa/survey_logic_file/sid/{SID}']],

// FIXME these FAIL !!
//['surveyResponsesIndex', ['route'=>'responses/sa/index/surveyid/{SID}']],
//['surveyResponsesBrowse', ['route'=>'responses/sa/browse/surveyid/{SID}']],

// this seems to be a special case, opens in another tab
//['printableSurvey', ['route'=>'printablesurvey/sa/index/surveyid/{SID}']],

// FIXME these views need an activated survey
//['dataEntryView', ['route'=>'dataentry/sa/view/surveyid/{SID}']],
//['statisticsIndex', ['route'=>'statistics/sa/index/surveyid/{SID}']],
//['exportResults', ['route'=>'export/sa/exportresults/surveyid/{SID}']],
//['exportSpss', ['route'=>'export/sa/exportspss/sid/{SID}']],



// adding elements to survey
['addQuestion', ['route'=>'questions/sa/newquestion/surveyid/{SID}']],
['addQuestionGroup', ['route'=>'questiongroups/sa/add/surveyid/{SID}']],
['importQuestionGroup', ['route'=>'questiongroups/sa/importview/surveyid/{SID}']],
['addQuota', ['route'=>'quotas/sa/newquota/surveyid/{SID}']],
// Below are views need an activated survey
['dataEntryView', ['route'=>'dataentry/sa/view/surveyid/{SID}','import_id'=>'454287', 'activate'=>true]],
['statisticsIndex', ['route'=>'statistics/sa/index/surveyid/{SID}']],
['exportResults', ['route'=>'export/sa/exportresults/surveyid/{SID}']],
['exportSpss', ['route'=>'export/sa/exportspss/sid/{SID}']],
['surveyResponsesIndex', ['route'=>'responses/sa/index/surveyid/{SID}']],
['surveyResponsesBrowse', ['route'=>'responses/sa/browse/surveyid/{SID}']],
['surveyParticipantsIndex', ['route'=>'tokens/sa/index/surveyid/{SID}']],


];

0 comments on commit 4aea797

Please sign in to comment.