From c5d16a52935a9ed047987378265808f50cd7e030 Mon Sep 17 00:00:00 2001 From: Denis Chenu Date: Wed, 31 Jul 2019 20:24:14 +0200 Subject: [PATCH] Dev: #15012: Must add test for min max EM function Dev: compare more than the issue, max is really mot used Dev: JS vs PHP compare + Fixed string --- .../limesurvey_survey_MinMaxCompareTest.lss | 1001 +++++++++++++++++ tests/surveys/MinMaxCompareTest.php | 80 ++ 2 files changed, 1081 insertions(+) create mode 100644 tests/data/surveys/limesurvey_survey_MinMaxCompareTest.lss create mode 100644 tests/surveys/MinMaxCompareTest.php diff --git a/tests/data/surveys/limesurvey_survey_MinMaxCompareTest.lss b/tests/data/surveys/limesurvey_survey_MinMaxCompareTest.lss new file mode 100644 index 00000000000..52ab9a5739c --- /dev/null +++ b/tests/data/surveys/limesurvey_survey_MinMaxCompareTest.lss @@ -0,0 +1,1001 @@ + + + Survey + 359 + + en + + + + qid + scale_id + sqid + language + specialtype + defaultvalue + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + gid + sid + group_name + group_order + description + language + randomization_group + grelevance + + + + + + + + + + + + + + + + + + + + + + + + + + + qid + parent_qid + sid + gid + type + title + question + preg + help + other + mandatory + question_order + language + scale_id + same_default + relevance + modulename + + + + + + + + + <![CDATA[MultiNum]]> + + + + + + + + + + + + + + + + + + + <![CDATA[MinMaxJS]]> + +
MultiNum
+
{min(that.MultiNum.sq_SQ.NAOK)}/{min(that.MultiNum.NAOK)}/{max(that.MultiNum.NAOK)}
+
MultiText
+
{min(that.MultiText.sq_SQ.NAOK)}/ {min(that.MultiText.NAOK)}/{max(that.MultiText.NAOK)}
+
MultiText2
+
{min(that.MultiText2.sq_SQ.NAOK)}/{min(that.MultiText2.NAOK)}/{max(that.MultiText2.NAOK)}
+
MultiText3
+
{min(that.MultiText3.sq_SQ.NAOK)}/{min(that.MultiText3.NAOK)}/{max(that.MultiText3.NAOK)}
+
MultiText4
+
{min(that.MultiText4.sq_SQ.NAOK)}/{min(that.MultiText4.NAOK)}/{max(that.MultiText4.NAOK)}
+]]>
+ + + + + + + + + + +
+ + + + + + + <![CDATA[MinMaxPHP]]> + +
MultiNum
+
{min(that.MultiNum.sq_SQ.NAOK)}/{min(that.MultiNum.NAOK)}/{max(that.MultiNum.NAOK)}
+
MultiText
+
{min(that.MultiText.sq_SQ.NAOK)}/ {min(that.MultiText.NAOK)}/{max(that.MultiText.NAOK)}
+
MultiText2
+
{min(that.MultiText2.sq_SQ.NAOK)}/{min(that.MultiText2.NAOK)}/{max(that.MultiText2.NAOK)}
+
MultiText3
+
{min(that.MultiText3.sq_SQ.NAOK)}/{min(that.MultiText3.NAOK)}/{max(that.MultiText3.NAOK)}
+
MultiText4
+
{min(that.MultiText4.sq_SQ.NAOK)}/{min(that.MultiText4.NAOK)}/{max(that.MultiText4.NAOK)}
+]]>
+ + + + + + + + + + +
+ + + + + + + <![CDATA[MultiText]]> + + + + + + + + + + + + + + + + + + + <![CDATA[MultiText2]]> + + + + + + + + + + + + + + + + + + <![CDATA[MultiText3]]> + + + + + + + + + + + + + + + + + + <![CDATA[MultiText4]]> + + + + + + + + + + + + +
+
+ + + qid + parent_qid + sid + gid + type + title + question + preg + help + other + mandatory + question_order + language + scale_id + same_default + relevance + modulename + + + + + + + + + <![CDATA[SQ001]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ002]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ003]]> + + + + + + + + + + + + + + + + + <![CDATA[Sblank]]> + + + + + + + + + + + + + + + + + <![CDATA[Snotrel]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ001]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ002]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ003]]> + + + + + + + + + + + + + + + + + <![CDATA[Sblank]]> + + + + + + + + + + + + + + + + + <![CDATA[Snorel]]> + + + + + + + + + + + + + + + + + <![CDATA[Sblank]]> + + + + + + + + + + + + + + + + + <![CDATA[Snorel]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ003]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ002]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ001]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ001]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ002]]> + + + + + + + + + + + + + + + + + <![CDATA[Snotrel]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ003]]> + + + + + + + + + + + + + + + + + <![CDATA[Sblank]]> + + + + + + + + + + + + + + + + + <![CDATA[Sblank]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ001]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ002]]> + + + + + + + + + + + + + + + + + <![CDATA[Snotrel]]> + + + + + + + + + + + + + + + + + <![CDATA[SQ003]]> + + + + + + + + + + + + + + + sid + gsid + admin + expires + startdate + adminemail + anonymized + faxto + format + savetimings + template + language + additional_languages + datestamp + usecookie + allowregister + allowsave + autonumber_start + autoredirect + allowprev + printanswers + ipaddr + refurl + showsurveypolicynotice + publicstatistics + publicgraphs + listpublic + htmlemail + sendconfirmation + tokenanswerspersistence + assessments + usecaptcha + usetokens + bounce_email + attributedescriptions + emailresponseto + emailnotificationto + tokenlength + showxquestions + showgroupinfo + shownoanswer + showqnumcode + bouncetime + bounceprocessing + bounceaccounttype + bounceaccounthost + bounceaccountpass + bounceaccountencryption + bounceaccountuser + showwelcome + showprogress + questionindex + navigationdelay + nokeyboard + alloweditaftercompletion + googleanalyticsstyle + googleanalyticsapikey + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + surveyls_survey_id + surveyls_language + surveyls_title + surveyls_description + surveyls_welcometext + surveyls_endtext + surveyls_policy_notice + surveyls_policy_error + surveyls_policy_notice_label + surveyls_url + surveyls_urldescription + surveyls_numberformat + + + + + + + + + +
MultiNum
+
{min(that.MultiNum.sq_SQ.NAOK)}/{min(that.MultiNum.NAOK)}/{max(that.MultiNum.NAOK)}
+
MultiText
+
{min(that.MultiText.sq_SQ.NAOK)}/ {min(that.MultiText.NAOK)}/{max(that.MultiText.NAOK)}
+
MultiText2
+
{min(that.MultiText2.sq_SQ.NAOK)}/{min(that.MultiText2.NAOK)}/{max(that.MultiText2.NAOK)}
+
MultiText3
+
{min(that.MultiText3.sq_SQ.NAOK)}/{min(that.MultiText3.NAOK)}/{max(that.MultiText3.NAOK)}
+
MultiText4
+
{min(that.MultiText4.sq_SQ.NAOK)}/{min(that.MultiText4.NAOK)}/{max(that.MultiText4.NAOK)}
+]]>
+ + + +
+
+
+ + + 387524 + vanilla + + + inherit + inherit + off + inherit + inherit + inherit + inherit + inherit + + + + +
diff --git a/tests/surveys/MinMaxCompareTest.php b/tests/surveys/MinMaxCompareTest.php new file mode 100644 index 00000000000..c61d1457d16 --- /dev/null +++ b/tests/surveys/MinMaxCompareTest.php @@ -0,0 +1,80 @@ +urlManager; + $urlMan->setBaseUrl('http://' . self::$domain . '/index.php'); + $url = $urlMan->createUrl( + 'survey/index', + [ + 'sid' => self::$surveyId, + 'newtest' => 'Y', + ] + ); + + // Get questions. + $survey = \Survey::model()->findByPk(self::$surveyId); + try { + // Get first page. + self::$webDriver->get($url); + + /* Fill JS result */ + $MultiNumResultJS = self::$webDriver->findElement(WebDriverBy::id('MultiNum'))->getText(); + $MultiTextResultJS = self::$webDriver->findElement(WebDriverBy::id('MultiText'))->getText(); + $MultiText2ResultJS = self::$webDriver->findElement(WebDriverBy::id('MultiText2'))->getText(); + $MultiText3ResultJS = self::$webDriver->findElement(WebDriverBy::id('MultiText3'))->getText(); + $MultiText4ResultJS = self::$webDriver->findElement(WebDriverBy::id('MultiText4'))->getText(); + + /* Move next */ + $nextButton = self::$webDriver->findElement(WebDriverBy::id('ls-button-submit')); + $nextButton->click(); + + /* Fill PHP result */ + $MultiNumResultPHP = self::$webDriver->findElement(WebDriverBy::id('MultiNum'))->getText(); + $MultiTextResultPHP = self::$webDriver->findElement(WebDriverBy::id('MultiText'))->getText(); + $MultiText2ResultPHP = self::$webDriver->findElement(WebDriverBy::id('MultiText2'))->getText(); + $MultiText3ResultPHP = self::$webDriver->findElement(WebDriverBy::id('MultiText3'))->getText(); + $MultiText4ResultPHP = self::$webDriver->findElement(WebDriverBy::id('MultiText4'))->getText(); + /* Do the JS vs PHP compare */ + $this->assertEquals($MultiNumResultJS, $MultiNumResultPHP, 'Comparaison with forced number : «' . $MultiNumResultJS ."» vs «".$MultiNumResultPHP."»"); + $this->assertEquals($MultiTextResultJS, $MultiTextResultPHP, 'Comparaison with number and string : «' . $MultiTextResultJS ."» vs «".$MultiTextResultPHP."»"); + $this->assertEquals($MultiText2ResultJS, $MultiText2ResultPHP, 'Comparaison with string : «' . $MultiText2ResultJS ."» vs «".$MultiText2ResultPHP."»"); + $this->assertEquals($MultiText3ResultJS, $MultiText3ResultPHP, 'Comparaison with number string start by number: «' . $MultiText3ResultJS ."» vs «".$MultiText3ResultPHP."»"); + $this->assertEquals($MultiText4ResultJS, $MultiText4ResultPHP, 'Comparaison with string and number : «' . $MultiText4ResultJS ."» vs «".$MultiText4ResultPHP."»"); + /* Fixed string compare (wait for) */ + $this->assertEquals($MultiNumResultPHP, "-2//4", 'Comparaison with forced number got «' . $MultiNumResultPHP ."», wait «-2//4»"); + $this->assertEquals($MultiTextResultPHP, "-1/ /Anything", 'Comparaison with number and string : got «' . $MultiTextResultPHP ."», wait «-1/ /Anything»"); + $this->assertEquals($MultiText2ResultPHP, "A//C", 'Comparaison with string : got «' . $MultiText2ResultPHP ."», wait «A//C»"); + $this->assertEquals($MultiText3ResultPHP, "1//4", 'Comparaison with string start by number: got «' . $MultiText3ResultPHP ."», wait «1//4»"); + $this->assertEquals($MultiText4ResultPHP, "//AAA", 'Comparaison with string and number : got «' . $MultiText4ResultPHP ."», wait «//AAA»"); + + } catch (\Exception $ex) { + $screenshot = self::$webDriver->takeScreenshot(); + $filename = self::$screenshotsFolder.'/MinMaxCompareTest_' . __FUNCTION__ . '.png'; + file_put_contents($filename, $screenshot); + $this->assertFalse( + true, + 'Url: ' . $url . PHP_EOL . + 'Screenshot in ' .$filename . PHP_EOL . $ex->getMessage() + ); + } + } +}