Beispiel #1
0
 /**
  * Create the home view
  */
 public function __construct()
 {
     parent::__construct();
     $template = new TextFile('./data/template.html');
     $template->load();
     $this->loadFile($template);
 }
Beispiel #2
0
 /**
  * Test html doc structure
  */
 public function testHtmlDoc()
 {
     $filename = DATA_PATH . '/doc.html';
     $file = new TextFile($filename);
     $file->load();
     $doc = new HtmlDoc();
     $doc->loadFile($file);
     $doc2 = HtmlDoc::createFromFilePath($filename);
     $this->assertInstanceOf('\\Duality\\Structure\\HtmlDoc', $doc2);
     $doc->setTitle('Duality dummy doc title');
     $result = (string) $doc;
     $expected = "<!DOCTYPE html>\n<html><head><title>Duality dummy doc title</title></head><body></body></html>\n";
     $this->assertEquals($expected, $result);
     $doc = HtmlDoc::createFromFilePath($filename);
     $doc->setAttribute('body', 'id', 'dummy');
     $result = (string) $doc;
     $expected = "<!DOCTYPE html>\n<html><head><title></title></head><body id=\"dummy\"></body></html>\n";
     $this->assertEquals($expected, $result);
     $doc = HtmlDoc::createFromFilePath($filename);
     $expected = "<!DOCTYPE html>\n<html><head><title></title></head><body><p>Dummy content</p></body></html>\n";
     $doc->appendTo('body', '<p>Dummy content</p>');
     $result = (string) $doc;
     $this->assertEquals($expected, $result);
 }
Beispiel #3
0
 /**
  * Creates an HTML document from file path
  * 
  * @param string $path Give the file to load the HTML into DOM document
  * 
  * @return \Duality\Structure\HtmlDoc A new HtmlDoc instance
  */
 public static function createFromFilePath($path)
 {
     $doc = new HtmlDoc();
     $template = new TextFile($path);
     $template->load();
     $template->getContent();
     $doc->loadFile($template);
     return $doc;
 }