Ejemplo n.º 1
0
    public function testRenderRecursive()
    {
        $img = new HtmlLeaf(['kind' => 'img', 'attr' => ['id' => 'img1', 'class' => 'wide', 'href' => 'public/img/image1.jpg']]);
        $div = new HtmlNode(['child' => [$img], 'attr' => ['id' => 'div1']]);
        $expected = '
$' . $img->getID() . ' = new \\Simphotonics\\Dom\\HtmlLeaf([
  \'kind\' => \'img\',
  \'attr\'=> [
    \'id\' => \'img1\',
    \'class\' => \'wide\',
    \'href\' => \'public/img/image1.jpg\'
  ],
]); 

$' . $div->getID() . ' = new \\Simphotonics\\Dom\\HtmlNode([
  \'kind\' => \'div\',
  \'attr\'=> [
    \'id\' => \'div1\'
  ],
  \'child\'=> [
    $' . $img->getID() . '
  ]
]); 
';
        $this->assertEquals($expected, Renderer::renderRecursive($div));
    }