Skip to content

Commit

Permalink
DEV: fixed tests for ipanonymize
Browse files Browse the repository at this point in the history
  • Loading branch information
Trischi80 committed Apr 21, 2020
1 parent bf9e12c commit b9cd075
Showing 1 changed file with 6 additions and 50 deletions.
Expand Up @@ -13,8 +13,6 @@ class IpAddressAnonymizeTest extends TestBaseClassWeb
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$surveyFile = self::$surveysFolder . '/limesurvey_survey_573837.lss';
self::importSurvey($surveyFile);

/* Login */
$username = getenv('ADMINUSERNAME');
Expand All @@ -36,6 +34,9 @@ public static function setUpBeforeClass()
*/
public function testIpAnonymizeInActiveSurvey()
{
$surveyFile = self::$surveysFolder . '/limesurvey_survey_573837.lss';
self::importSurvey($surveyFile);

$urlMan = \Yii::app()->urlManager;
$urlMan->setBaseUrl('http://' . self::$domain . '/index.php');
$url = $urlMan->createUrl(
Expand Down Expand Up @@ -81,34 +82,16 @@ public function testIpAnonymizeInActiveSurvey()

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

//after this deactivate survey for next test ...
// Switch to first window.
$windowHandles = self::$webDriver->getWindowHandles();
self::$webDriver->switchTo()->window(
reset($windowHandles)
);

//click button stop this survey
$stopSurveyButton = self::$webDriver->findElement(WebDriverBy::id('ls-stop-survey'));
$stopSurveyButton->click();
sleep(1);

//click to deactivate survey
$execute = self::$webDriver->wait(10)->until(
WebDriverExpectedCondition::elementToBeClickable(
WebDriverBy::cssSelector('input[type="submit"][value="Deactivate survey"]')
)
);
$execute->click();
sleep(2);
}

/**
* Test so that previous behaviour is still working.
*/
public function testNormalActiveSurvey()
{
// TODO: As above, but without ip anon and ip === 127.0.0.1
$surveyFile = self::$surveysFolder . '/limesurvey_survey_573837.lss';
self::importSurvey($surveyFile);

$urlMan = \Yii::app()->urlManager;
$urlMan->setBaseUrl('http://' . self::$domain . '/index.php');
$url = $urlMan->createUrl(
Expand Down Expand Up @@ -155,33 +138,6 @@ public function testNormalActiveSurvey()

sleep(2);

/*
// Enter answer text. (this must be only for the second test, i don't know why?!?!
$survey = \Survey::model()->findByPk(self::$surveyId);
$questionObjects = $survey->groups[0]->questions;
$questions = [];
foreach ($questionObjects as $q) {
$questions[$q->title] = $q;
}
$sgqa = self::$surveyId . 'X' . $survey->groups[0]->gid . 'X' . $questions['G01Q01']->qid;
$question = self::$webDriver->findElement(WebDriverBy::id('answer' . $sgqa));
$question->sendKeys('foo bar');
sleep(2);
// Click submit.
/*
$submitButton = self::$webDriver->wait(10)->until(
WebDriverExpectedCondition::elementToBeClickable(
WebDriverBy::cssSelector('input[type="submit"][value="movesubmit"]')
)
);
$submitButton = self::$webDriver->findElement(WebDriverBy::id('ls-button-submit'));
$submitButton->click();
sleep(2); */

//now check if ip was anonymized (ipv4, last digit should be 0)
//get ipadr from table survey_573837 ...
$models = \Response::model(self::$surveyId)->findAll();
Expand Down

0 comments on commit b9cd075

Please sign in to comment.