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)); }
public function testRenderDTD() { HtmlLeaf::setDTD('html5'); $dtd = new HtmlLeaf(['kind' => '!DOCTYPE']); // Empty content => The static variable HtmlLeaf::$dtd // will be used as element content! $this->assertEquals('<!DOCTYPE html5 >', "{$dtd}"); // If a content is set, it overwrites the default content. $dtd->setCont('html5-test'); $this->assertEquals('<!DOCTYPE html5-test >', "{$dtd}"); }
/** * Constructs HtmlTitle object * @param string $domainName Prefix used to generate web page title. * @param string $titleString Overwrites autogenerated titles. * @param const $flag Formats autogenerated titles. */ public function __construct($domainName = 'DEFAULT DOMAIN', $titleString = 'Default Title', $flag = self::FIRST_TO_UPPER_CASE) { switch (func_num_args()) { case 0: $titleString = self::getTitle($flag); break; case 1: $titleString = $domainName . " - " . self::getTitle($flag); break; default: $titleString = $domainName . " - " . $titleString; break; } parent::__construct(['kind' => 'title', 'cont' => $titleString]); }
/** * Returns string containing Css link element. * Note: The path to the Css files is generated in this function! * @method __toString * @return string */ public function __toString() { $this->path = $this->cssFolder . '/' . $this->cssFile . '.css'; return parent::__toString(); }