Exemplo n.º 1
0
 public function testMarshallUl()
 {
     $strong = new Strong();
     $strong->setContent(new InlineCollection(array(new TextRun('text'))));
     $li1 = new Li();
     $li1->setContent(new FlowCollection(array(new TextRun('Simple '), $strong, new TextRun('.'))));
     $em = new Em();
     $em->setContent(new InlineCollection(array(new TextRun('text'))));
     $p = new P();
     $p->setContent(new InlineCollection(array(new TextRun('Some complex text.'))));
     $li3 = new Li();
     $li3->setContent(new FlowCollection(array(new TextRun('Some super '), $em, new TextRun(':'), $p)));
     $ol = new Ol();
     $ol->setId('ordered-list');
     $ol->setContent(new LiCollection(array($li3)));
     $li2 = new Li();
     $li2->setContent(new FlowCollection(array(new TextRun('olé '), $ol)));
     $ul = new Ul();
     $ul->setClass('my-qti-list');
     $ul->setContent(new LiCollection(array($li1, $li2)));
     $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($ul)->marshall($ul);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<ul class="my-qti-list"><li>Simple <strong>text</strong>.</li><li>olé <ol id="ordered-list"><li>Some super <em>text</em>:<p>Some complex text.</p></li></ol></li></ul>', $dom->saveXML($element));
 }
Exemplo n.º 2
0
 public function testMarshall()
 {
     $li1 = new Li();
     $li1->setContent(new FlowCollection(array(new TextRun('Start the Game'))));
     $li2 = new Li();
     $li2->setContent(new FlowCollection(array(new TextRun('Configure Inputs'))));
     $li3 = new Li();
     $li3->setContent(new FlowCollection(array(new TextRun('Hall of Fame'))));
     $li4 = new Li();
     $li4->setContent(new FlowCollection(array(new TextRun('Quit'))));
     $ul = new Ul();
     $ul->setContent(new LiCollection(array($li1, $li2, $li3, $li4)));
     $divMenu = new Div('menu');
     $divMenu->setContent(new FlowCollection(array($ul)));
     $h1 = new H1();
     $h1->setContent(new InlineCollection(array(new TextRun('Escape from Death Star'))));
     $strong = new Strong();
     $strong->setContent(new InlineCollection(array(new TextRun('incredible'))));
     $p = new P();
     $p->setClass('short-story');
     $p->setContent(new InlineCollection(array(new TextRun('An '), $strong, new TextRun(' adventure.'))));
     $divContent = new Div('content');
     $divContent->setContent(new FlowCollection(array($h1, $p)));
     $divContainer = new Div('main-container', 'ui-pane');
     $divContainer->setContent(new FlowCollection(array($divMenu, $divContent)));
     $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($divContainer)->marshall($divContainer);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $expected = '<div id="main-container" class="ui-pane"><div id="menu"><ul><li>Start the Game</li><li>Configure Inputs</li><li>Hall of Fame</li><li>Quit</li></ul></div><div id="content"><h1>Escape from Death Star</h1><p class="short-story">An <strong>incredible</strong> adventure.</p></div></div>';
     $this->assertEquals($expected, $dom->saveXML($element));
 }