コード例 #1
0
 public function testRender()
 {
     $ctx = new XhtmlRenderingEngine();
     $textRun = new TextRun('test text');
     $renderer = new TextRunRenderer();
     $renderer->setRenderingEngine($ctx);
     $xhtml = $renderer->render($textRun);
     $node = $xhtml->firstChild;
     $this->assertEquals('test text', $node->wholeText);
 }
コード例 #2
0
 public function testRenderChildren()
 {
     $ctx = new XhtmlRenderingEngine();
     $abbr = new Abbr('my-abbr', 'qti qti-abbr');
     $abbrRenderer = new BodyElementRenderer();
     $abbrRenderer->setRenderingEngine($ctx);
     $textRun = new TextRun('abbreviation...');
     $textRunRenderer = new TextRunRenderer();
     $textRunRenderer->setRenderingEngine($ctx);
     $renderedTextRun = $textRunRenderer->render($textRun);
     $ctx->storeRendering($textRun, $renderedTextRun);
     $abbr->setContent(new InlineCollection(array($textRun)));
     $element = $abbrRenderer->render($abbr)->firstChild;
     $this->assertEquals('abbr', $element->nodeName);
     $this->assertEquals('my-abbr', $element->getAttribute('id'));
     $this->assertEquals('qti qti-abbr qti-bodyElement qti-abbr', $element->getAttribute('class'));
     $this->assertEquals('abbreviation...', $element->firstChild->wholeText);
 }