Skip to content

Commit

Permalink
Dev: Add some test code for how to use node with LEMval()
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Aug 22, 2017
1 parent 30633f4 commit 5a8a1ef
Showing 1 changed file with 57 additions and 6 deletions.
63 changes: 57 additions & 6 deletions tests/helpers/ExpressionCoreHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function testCompareNumberLtSpace()
/**
* Expression: '3' < 'A'
*/
public function testNumberLtLetter()
public function testCompareNumberLtLetter()
{
$sgqa = '563168X136X5376';
$expression = '((563168X136X5376.NAOK < "A"))';
Expand All @@ -166,7 +166,7 @@ public function testNumberLtLetter()
/**
* '3' <= ' '
*/
public function testNumberLeSpace()
public function testCompareNumberLeSpace()
{
$sgqa = '563168X136X5376';
$expression = '((563168X136X5376.NAOK <= " "))';
Expand All @@ -177,7 +177,7 @@ public function testNumberLeSpace()
/**
* '3' <= ''
*/
public function testNumberLeEmpty()
public function testCompareNumberLeEmpty()
{
$sgqa = '563168X136X5376';
$expression = '((563168X136X5376.NAOK <= ""))';
Expand All @@ -188,7 +188,7 @@ public function testNumberLeEmpty()
/**
* '' <= ' '
*/
public function testEmptyLeSpace()
public function testCompareEmptyLeSpace()
{
$sgqa = '563168X136X5376';
$expression = '((563168X136X5376.NAOK <= " "))';
Expand Down Expand Up @@ -268,7 +268,7 @@ public function testCompareNumberGeSpace()
/**
* Expression: 3 + '2'
*/
public function testNumberPlusString()
public function testCompareNumberPlusString()
{
$sgqa = '563168X136X5376';
$expression = '((563168X136X5376.NAOK + "2"))';
Expand All @@ -281,7 +281,7 @@ public function testNumberPlusString()
* Expression: 3 + 2
* @todo Need LEMval() to work.
*/
public function testNumberPlusNumber()
public function testCompareNumberPlusNumber()
{
$sgqa = '563168X136X5376';
$expression = '((563168X136X5376.NAOK + 2))';
Expand Down Expand Up @@ -350,6 +350,57 @@ protected function runNode($js)
return $output;
}

/**
* @group node
*/
public function testNode()
{
$code = "
eval(fs.readFileSync('./test.js', {encoding: 'utf8'}));
LEMradix = ',';
LEMmode = 'survey';
document = {
getElementById: function(id) {
//console.log(id);
if (id == 'relevance5376' || id == 'relevance' || id == 'relevanceG0') {
return {value: 1};
}
return {value: 123};
}
}
LEMalias2varName = {
'test': 'java563168X136X5376',
'563168X136X5376': 'java563168X136X5376'
};
LEMvarNameAttr = {
'java563168X136X5376': {
'jsName':'java563168X136X5376',
'jsName_on':'java563168X136X5376',
'sgqa':'563168X136X5376',
'qid':5376,
'gid':136,
'type':'Y',
'default':'',
'rowdivid':'',
'onlynum':'',
'gseq':0,
'answers': {
'Y':'Ja',
'N':'Nei'
}
},
};
LEMval('563168X136X5376.NAOK');
";
$command = sprintf(
'node -p "%s"',
$code
);
$output = [];
exec($command, $output);
var_dump($output);
}

/**
*
*/
Expand Down

0 comments on commit 5a8a1ef

Please sign in to comment.