/** * @covers toNode * @dataProvider getDataForTestCreateTest */ public function testCreate($name, $value, $expectedObj) { $variable = Variable::create($name, $value); $node = $variable->toNode(); // convert to node $this->assertEquals($node, $expectedObj); }
/** * Prepare variable to be used as nodes. * * @param Context $context * @param array $variables */ protected function prepareVariables(Context $context, array $variables) { // FIXME: flag to mark variables as prepared! $prepared = []; foreach ($variables as $name => $value) { // user provided node, no need to process it further if ($value instanceof Node) { $prepared[] = $value; continue; } // this is not an "real" variable if (!$value instanceof Variable) { $value = Variable::create($name, $value); } $prepared[] = $value->toNode(); } if (count($prepared)) { $context->customVariables = new RulesetNode([], $prepared); } }