Skip to content

Commit

Permalink
Add test for execute question theme survey
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Jun 14, 2021
1 parent 099f787 commit 5a91240
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
Binary file not shown.
Expand Up @@ -81,7 +81,6 @@ public function testIpAnonymizeInActiveSurvey()
$models = \Response::model(self::$surveyId)->findAll();

$this->assertTrue((isset($models[0]->ipaddr)) && ($models[0]->ipaddr==='127.0.0.0'));

}

/**
Expand Down
52 changes: 46 additions & 6 deletions tests/functional/backend/QuestionThemeTest.php
Expand Up @@ -85,7 +85,6 @@ public function testImportQuestionTheme()
*/
public function testSelectQuestionThemeInQuestionEditor()
{

// Import survey with one group and question
$surveyFile = self::$surveysFolder . '/limesurvey_survey_193959_testSelectQuestionThemeInEditor.lss';
self::importSurvey($surveyFile);
Expand Down Expand Up @@ -182,15 +181,56 @@ public function testSelectQuestionThemeInQuestionEditor()
}

/**
* @depends testSelectQuestionThemeInQuestionEditor
*/
public function testPreviewQuestionThemeQuestion()
public function testExecuteQuestionThemeSurvey()
{
// Use previous survey
// Activate survey
//* @depends testImportQuestionTheme
// Import lsa
$surveyFile = self::$surveysFolder . '/survey_archive_222923_executeQuestionThemeSurvey.lsa';
self::importSurvey($surveyFile);

$urlMan = \Yii::app()->urlManager;
$web = self::$webDriver;

// Go to survey overview.
$url = $urlMan->createUrl(
'surveyAdministration/view/surveyid/' . self::$surveyId
);
self::$webDriver->get($url);

// Execute survey
// Answer question using question theme
$button = self::$webDriver->findById('execute_survey_button') ;
$button->click();
sleep(1);

// Switch to new tab.
$windowHandles = self::$webDriver->getWindowHandles();
self::$webDriver->switchTo()->window(
end($windowHandles)
);
sleep(1);

// Click on slider to trigger answering.
$sliderHandler = $web->findByCss('.slider-handle');
$sliderHandler->click();

// Submit
$nextButton = self::$webDriver->findElement(WebDriverBy::id('ls-button-submit'));
$nextButton->click();
sleep(1);

// Check result in database
$responses = \Response::model(self::$surveyId)->findAll();
$this->assertCount(1, $responses);

$sid = self::$surveyId;
$gid = self::$testSurvey->groups[0]->gid;
$qid = self::$testSurvey->questions[0]->qid;

$sgqa1 = sprintf('%dX%dX%dSQ001', $sid, $gid, $qid);
$sgqa2 = sprintf('%dX%dX%dSQ002', $sid, $gid, $qid);

$this->assertEquals(4, (int) $responses[0]->attributes[$sgqa1]);
$this->assertEquals(7, (int) $responses[0]->attributes[$sgqa2]);
}
}

0 comments on commit 5a91240

Please sign in to comment.