Skip to content

Commit

Permalink
Dev: Add EM test for 3 + '2'
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt authored and LouisGac committed Aug 28, 2017
1 parent cd7f13c commit 9e2b15c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tests/helpers/ExpressionCoreHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,24 @@ public function testCompareNumberGeSpace()
$this->compareExpression($sgqa, $value, $expression);
}

/**
* Expression: 3 + '2'
*/
public function testNumberPlusString()
{
$sgqa = '563168X136X5376';
$expression = '((563168X136X5376.NAOK + "2"))';
$value = 3;
$jsonEncodeResult = false;
$this->compareExpression($sgqa, $value, $expression, $jsonEncodeResult);
}

/**
* @param string $sgqa
* @param string $expression
* @return void
*/
protected function compareExpression($sgqa, $value, $expression)
protected function compareExpression($sgqa, $value, $expression, $jsonEncode = true)
{
// Input value 3.
$_SESSION['survey_563168'][$sgqa] = $value;
Expand All @@ -248,14 +260,18 @@ protected function compareExpression($sgqa, $value, $expression)

$result = $em->GetResult();

if ($jsonEncode) {
$result = json_encode($result);
}

$errors = $em->RDP_GetErrors();
$this->assertEmpty($errors);
$js = $em->GetJavaScriptEquivalentOfExpression();

$nodeOutput = $this->runNode($js);

$this->assertCount(1, $nodeOutput);
$this->assertEquals(json_encode($result), $nodeOutput[0], 'JS and PHP must return same result');
$this->assertEquals($result, $nodeOutput[0], 'JS and PHP must return same result');
}

/**
Expand Down

0 comments on commit 9e2b15c

Please sign in to comment.