Ejemplo 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));
 }
 public function testMarshallComplex()
 {
     $component = new InfoControl('controlMePlease');
     $component->setId('controlMePlease');
     $em = new Em();
     $em->setContent(new InlineCollection(array(new TextRun('gooood'))));
     $component->setContent(new FlowStaticCollection(array(new TextRun('This is '), $em, new TextRun(' !'))));
     $element = $this->getMarshallerFactory()->createMarshaller($component)->marshall($component);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<infoControl id="controlMePlease">This is <em>gooood</em> !</infoControl>', $dom->saveXML($element));
 }
 public function testMarshallP()
 {
     $p = new P('my-p');
     $em = new Em();
     $em->setContent(new InlineCollection(array(new TextRun('simple'))));
     $p->setContent(new InlineCollection(array(new TextRun('This text is a '), $em, new TextRun(' test.'))));
     $marshaller = $this->getMarshallerFactory()->createMarshaller($p);
     $element = $marshaller->marshall($p);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<p id="my-p">This text is a <em>simple</em> test.</p>', $dom->saveXML($element));
 }
Ejemplo n.º 4
0
 public function testMarshall21()
 {
     $strong = new Strong('john');
     $strong->setLabel('His name');
     $strong->setContent(new InlineCollection(array(new TextRun('John Dunbar'))));
     $em = new Em('sentence', 'introduction', 'en-US');
     $em->setContent(new InlineCollection(array(new TextRun('He is '), $strong, new TextRun('.'))));
     $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($em);
     $element = $marshaller->marshall($em);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<em id="sentence" class="introduction" xml:lang="en-US">He is <strong id="john" label="His name">John Dunbar</strong>.</em>', $dom->saveXML($element));
 }