/** * */ public function testRead() { $escape = function ($str) { return htmlspecialchars($str, ENT_COMPAT, 'UTF-8'); }; $data = ['type' => 'ninja', 'color' => 'black', 'font' => 'sans', 'margin' => ['left' => '15px', 'right' => 'delete-me'], 'small' => ['font' => 'monospace', 'test' => '(a < b)'], 'auto' => new DataObject(['type' => 'auto', 'value' => time()]), 'func' => function () { return 'func'; }]; $root = new Node($data, ['escape' => $escape]); // $type = $root->node('type'); $font = $root->node('small.font'); $small = $root->node('small'); $color = $small->node('color', Node::BUBBLE); $res1 = $root->resolve('small.test'); $res2 = $root->render('{{small.test}}'); $res3 = $root->render('[{{small.font}}]'); $res4 = $root->render('COLOR {{color}} MARGIN {{margin.left}} END'); $auto = $root->node('auto.type'); $func = $root->resolve('func'); $doe = $root->node('small.johndoe'); $this->assertEquals($type, 'ninja'); $this->assertEquals($font, 'monospace'); $this->assertEquals($color, 'black'); $this->assertEquals($res1, '(a < b)'); $this->assertEquals($res2, '(a < b)'); $this->assertEquals($res3, '[monospace]'); $this->assertEquals($res4, 'COLOR black MARGIN 15px END'); $this->assertEquals($auto, 'auto'); $this->assertEquals($func, 'func'); $this->assertEquals($doe->exists(), false); }