Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into test-restructure10
Browse files Browse the repository at this point in the history
  • Loading branch information
TonisOrmisson committed Jan 10, 2018
2 parents 268071f + 51495c7 commit ad8fd36
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 62 deletions.
2 changes: 1 addition & 1 deletion application/controllers/survey/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function action()
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."survey_runtime.js");

if (is_null($thissurvey) && !is_null($surveyid)) {
$thissurvey = getSurveyInfo($surveyid);
$thissurvey = getSurveyInfo($surveyid);
}

// unused vars in this method (used in methods using compacted method vars)
Expand Down
22 changes: 11 additions & 11 deletions application/core/UserIdentity.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,33 @@ public function authenticate($sOneTimePassword = '')
$this->errorCode = self::ERROR_USERNAME_INVALID;
return !$this->errorCode;
}

if ($sOneTimePassword != '' && Yii::app()->getConfig("use_one_time_passwords") && md5($sOneTimePassword) == $user->one_time_pw) {
$user->one_time_pw = '';
$user->save();
$this->id = $user->uid;
$this->user = $user;
$this->errorCode = self::ERROR_NONE;
} elseif ($user->checkPassword($this->password)) {
} elseif (!$user->checkPassword($this->password)) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
$this->id = $user->uid;
$this->user = $user;
$this->errorCode = self::ERROR_NONE;
}
} elseif (Yii::app()->getConfig("auth_webserver") === true && (isset($_SERVER['PHP_AUTH_USER']) || isset($_SERVER['LOGON_USER']) || isset($_SERVER['REMOTE_USER']))) {
// normal login through webserver authentication
// normal login through webserver authentication
if (isset($_SERVER['PHP_AUTH_USER'])) {
$sUser = $_SERVER['PHP_AUTH_USER'];
} elseif (isset($_SERVER['REMOTE_USER'])) {
$sUser = $_SERVER['REMOTE_USER'];
} else {
$sUser = $_SERVER['LOGON_USER'];
}
}
if (strpos($sUser, "\\") !== false) {
$sUser = (string) substr($sUser, strrpos($sUser, "\\") + 1);
}

$aUserMappings = Yii::app()->getConfig("auth_webserver_user_map");
if (isset($aUserMappings[$sUser])) {
$sUser = $aUserMappings[$sUser];
Expand All @@ -73,16 +73,16 @@ public function authenticate($sOneTimePassword = '')
// describing the defaukt profile for this user
$aUserProfile = hook_get_auth_webserver_profile($sUser);
} elseif (Yii::app()->getConfig("auth_webserver_autocreate_user")) {
$aUserProfile = Yii::app()->getConfig("auth_webserver_autocreate_profile");
$aUserProfile = Yii::app()->getConfig("auth_webserver_autocreate_profile");
}
} else {
$this->id = $oUser->uid;
$this->user = $oUser;
$this->errorCode = self::ERROR_NONE;
}



if (Yii::app()->getConfig("auth_webserver_autocreate_user") && isset($aUserProfile) && is_null($oUser)) {
// user doesn't exist but auto-create user is set
$oUser = new User;
Expand All @@ -105,8 +105,8 @@ public function authenticate($sOneTimePassword = '')

// read again user from newly created entry
$this->id = $oUser->uid;
$this->user = $oUser;
$this->errorCode = self::ERROR_NONE;
$this->user = $oUser;
$this->errorCode = self::ERROR_NONE;
} else {
$this->errorCode = self::ERROR_USERNAME_INVALID;
}
Expand Down
6 changes: 6 additions & 0 deletions application/helpers/SurveyRuntimeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,12 @@ private function displayFirstPageIfNeeded()
if ($this->sSurveyMode != 'survey' && $_SESSION[$this->LEMsessid]['step'] == 0) {
$_SESSION[$this->LEMsessid]['test'] = time();

// TODO: Find out why language is not fetched correctly the first time.
$this->aSurveyInfo = getSurveyInfo(
$this->thissurvey['sid'],
$_SESSION['survey_'.$this->thissurvey['sid']]['s_lang']
);

display_first_page($this->thissurvey, $this->aSurveyInfo);
Yii::app()->end(); // So we can still see debug messages
}
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/common_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Translation helper function
* @param string $sToTranslate
* @param string $sEscapeMode Valid values are html (this is the default, js and unescaped
* @param string $sEscapeMode Valid values are html (this is the default, js and unescaped)
* @param string $sLanguage
* @return mixed|string
*/
Expand Down
11 changes: 8 additions & 3 deletions application/views/admin/survey/surveySummary_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,21 @@
?>
<!-- START surveySummary -->
<div class="row">
<div class="col-sm-12 h3 pagetitle"><?php eT('Survey summary'); ?></div>
<div class="col-sm-12 h3 pagetitle">
<?php eT('Survey summary'); ?> :
<?php echo flattenText($oSurvey->currentLanguageSettings->surveyls_title)." (".gT("ID")." ".$oSurvey->sid.")";?>
</div>
</div>
<?php /*
/// Survey quick actions have been removed -> deprecated
<div class="row">
<div class="col-sm-12">
<?php echo $this->renderPartial('/admin/survey/subview/_survey_quickaction', $subviewData); ?>
</div>
</div>
<div class="row">
*/ ?>
<div class="row ls-space margin top-10">
<!-- Survey summary -->
<div class="col-sm-12 h4"><?php echo flattenText($oSurvey->currentLanguageSettings->surveyls_title)." (".gT("ID")." ".$oSurvey->sid.")";?></div>
<div class="col-md-12 col-lg-6">
<div class="panel panel-default">
<!-- Default panel contents -->
Expand Down
54 changes: 12 additions & 42 deletions tests/acceptance/admin/CreateSurveyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,23 +143,15 @@ public function testCreateSurvey()

sleep(1);

// In case quick actions are hidden, show them.
try {
$showquickactions = self::$webDriver->wait(1)->until(
WebDriverExpectedCondition::elementToBeClickable(
WebDriverBy::cssSelector('#survey-action-chevron i.fa-caret-down')
)
);
$showquickactions->click();
sleep(1);
} catch (NoSuchElementException $ex) {
// Ignore
}
// Go to structure sidebar
$selectStructureSidebar = self::$webDriver->findElement(WebDriverBy::id('adminpanel__sidebar--selectorStructureButton'));
$selectStructureSidebar->click();


// Click "Add group".
$addgroup = self::$webDriver->wait(10)->until(
WebDriverExpectedCondition::elementToBeClickable(
WebDriverBy::cssSelector('#panel-1 .panel-body-link a')
WebDriverBy::id('adminpanel__sidebar--selectorCreateQuestionGroup')
)
);
$addgroup->click();
Expand All @@ -168,37 +160,12 @@ public function testCreateSurvey()
$groupname = self::$webDriver->findElement(WebDriverBy::id('group_name_en'));
$groupname->clear()->sendKeys('group1');

// Click save.
$save = self::$webDriver->findElement(WebDriverBy::id('save-button'));
$save->click();

// Click "Overview".
// TODO: No save-and-close for survey group yet.
$overview = self::$webDriver->findElement(WebDriverBy::id('sidemenu_1_1'));
$overview->click();

sleep(1);

// In case quick actions are hidden, show them.
try {
$showquickactions = self::$webDriver->wait(1)->until(
WebDriverExpectedCondition::elementToBeClickable(
WebDriverBy::cssSelector('#survey-action-chevron i.fa-caret-down')
)
);
$showquickactions->click();
sleep(1);
} catch (NoSuchElementException $ex) {
// Ignore
}

// Click "Add question".
$addgroup = self::$webDriver->wait(5)->until(
WebDriverExpectedCondition::elementToBeClickable(
WebDriverBy::cssSelector('#panel-2 .panel-body-link a')
)
);
$addgroup->click();
// Click save and add question.
$save = self::$webDriver->findElement(WebDriverBy::id('save-and-new-question-button'));
$save->click();
sleep(3);

// Add question title.
$groupname = self::$webDriver->findElement(WebDriverBy::id('title'));
Expand All @@ -209,6 +176,9 @@ public function testCreateSurvey()
$save->click();

sleep(1);

$selectSettingsSidebar = self::$webDriver->findElement(WebDriverBy::id('adminpanel__sidebar--selectorSettingsButton'));
$selectSettingsSidebar->click();

// Click "Overview".
$overview = self::$webDriver->wait(10)->until(
Expand Down
13 changes: 11 additions & 2 deletions tests/acceptance/surveys/AjaxModeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,25 @@
class AjaxModeTest extends TestBaseClassWeb
{
/**
*
* Setup before class.
*/
public function testAjaxModeRecordsAnswer()
public static function setupBeforeClass()
{
parent::setUpBeforeClass();

// Import survey.
$surveyFile = self::$surveysFolder . '/limesurvey_survey_366446.lss';
self::importSurvey($surveyFile);

// Activate survey.
self::$testHelper->activateSurvey(self::$surveyId);
}

/**
* Test that Ajax mode records answer.
*/
public function testAjaxModeRecordsAnswer()
{

// Get questions.
$survey = \Survey::model()->findByPk(self::$surveyId);
Expand Down
6 changes: 4 additions & 2 deletions tests/resources/views/adminGeneralSettingsViews.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
['homepageSettings', ['route'=>'homepagesettings']],
['createNewBox', ['route'=>'homepagesettings/sa/create']],
['pluginManager', ['route'=>'pluginmanager/sa/index']],
['configurePlugin', ['route'=>'pluginmanager/sa/configure&id=2']],
// TODO: Can't hardcode &id=2 if you using other urlFormat (path).
//['configurePlugin', ['route'=>'pluginmanager/sa/configure&id=2']],
['surveyMenus', ['route'=>'menus/sa/view']],
['surveyMenuEntries', ['route'=>'menuentries/sa/view']],
['templateOptions', ['route'=>'themeoptions']],
['surveyTemplateOptionsUpdate', ['route'=>'themeoptions/sa/update&id=1']],
// TODO: Can't hardcode &id=1 if you using other urlFormat (path).
//['surveyTemplateOptionsUpdate', ['route'=>'themeoptions/sa/update&id=1']],
['themeEditor', ['route'=>'themes/sa/view&templatename=fruity']],

];

0 comments on commit ad8fd36

Please sign in to comment.