Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dev: Add new test for save dual scale answer options
- Loading branch information
1 parent
4f57496
commit 0365a17
Showing
2 changed files
with
521 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
namespace ls\tests; | ||
|
||
use Facebook\WebDriver\WebDriverBy; | ||
use Facebook\WebDriver\WebDriverKeys; | ||
use Facebook\WebDriver\WebDriverExpectedCondition; | ||
use Facebook\WebDriver\Exception\NoSuchElementException; | ||
use Facebook\WebDriver\Exception\StaleElementReferenceException; | ||
use Facebook\WebDriver\Exception\UnknownServerException; | ||
use Facebook\WebDriver\Exception\TimeOutException; | ||
use Facebook\WebDriver\Exception\ElementNotVisibleException; | ||
|
||
/** | ||
* @since 2017-11-24 | ||
* @group dualscale | ||
*/ | ||
class SaveDualScaleAnswerOptionsTest extends TestBaseClassWeb | ||
{ | ||
/** | ||
* | ||
*/ | ||
public static function setupBeforeClass() | ||
{ | ||
parent::setupBeforeClass(); | ||
|
||
// Permission to everything. | ||
\Yii::app()->session['loginID'] = 1; | ||
|
||
$username = getenv('ADMINUSERNAME'); | ||
if (!$username) { | ||
$username = 'admin'; | ||
} | ||
|
||
$password = getenv('PASSWORD'); | ||
if (!$password) { | ||
$password = 'password'; | ||
} | ||
|
||
// Permission to everything. | ||
\Yii::app()->session['loginID'] = 1; | ||
|
||
// Browser login. | ||
self::adminLogin($username, $password); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testBasic() | ||
{ | ||
// Import survey with dual scale question type. | ||
$surveyFile = self::$surveysFolder . '/limesurvey_survey_677328.lss'; | ||
self::importSurvey($surveyFile); | ||
|
||
// Get questions. | ||
$survey = \Survey::model()->findByPk(self::$surveyId); | ||
$this->assertNotEmpty($survey); | ||
$this->assertCount(1, $survey->groups, 'Wrong number of groups: ' . count($survey->groups)); | ||
$this->assertCount(1, $survey->groups[0]->questions, 'We have exactly one question'); | ||
|
||
$urlMan = \Yii::app()->urlManager; | ||
$urlMan->setBaseUrl('http://' . self::$domain . '/index.php'); | ||
//http://localhost/lime25/limesurvey/index.php?r=admin/questions/sa/answeroptions/surveyid/677328/gid/195/qid/576 | ||
$url = $urlMan->createUrl( | ||
'admin/questions', | ||
[ | ||
'sa' => 'answeroptions', | ||
'surveyid' => self::$surveyId, | ||
'gid' => $survey->groups[0]->gid, | ||
'qid' => $survey->groups[0]->questions[0]->qid | ||
] | ||
); | ||
|
||
self::$webDriver->get($url); | ||
|
||
$answer1 = self::$webDriver->findElement(WebDriverBy::cssSelector('input[name="answer_en_1_0"]')); | ||
$answer1->sendKeys('123'); | ||
|
||
$answer2 = self::$webDriver->findElement(WebDriverBy::cssSelector('input[name="answer_en_1_1"]')); | ||
$answer2->sendKeys('abc'); | ||
|
||
$savebutton = self::$webDriver->findElement(WebDriverBy::id('save-button')); | ||
$savebutton->click(); | ||
|
||
$notif = self::$webDriver->findElement(WebDriverBy::id('notif-container')); | ||
$notifText = $notif->getText(); | ||
$this->assertContains('Answer options were successfully saved', $notifText); | ||
|
||
$answers = \Answer::model()->findAllByAttributes(['qid' => $survey->groups[0]->questions[0]->qid]); | ||
$this->assertCount(2, $answers, 'Two answer options saved'); | ||
} | ||
} |
Oops, something went wrong.