public function testMarshall()
 {
     $h1 = new H1();
     $h1->setContent(new InlineCollection(array(new TextRun('Super Item'))));
     $div = new Div();
     $div->setContent(new FlowCollection(array(new TextRun('This is some stimulus.'))));
     $itemBody = new ItemBody('my-body');
     $itemBody->setContent(new BlockCollection(array($h1, $div)));
     $element = $this->getMarshallerFactory()->createMarshaller($itemBody)->marshall($itemBody);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<itemBody id="my-body"><h1>Super Item</h1><div>This is some stimulus.</div></itemBody>', $dom->saveXML($element));
 }
Example #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));
 }