Пример #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 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));
 }
 public function testMarshall()
 {
     $simpleChoice = new SimpleAssociableChoice('choice_1', 1);
     $simpleChoice->setClass('qti-simpleAssociableChoice');
     $strong = new Strong();
     $strong->setContent(new InlineCollection(array(new TextRun('strong'))));
     $simpleChoice->setContent(new FlowStaticCollection(array(new TextRun('This is ... '), $strong, new TextRun('!'))));
     $marshaller = $this->getMarshallerFactory()->createMarshaller($simpleChoice);
     $element = $marshaller->marshall($simpleChoice);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<simpleAssociableChoice class="qti-simpleAssociableChoice" identifier="choice_1" matchMax="1">This is ... <strong>strong</strong>!</simpleAssociableChoice>', $dom->saveXML($element));
 }
Пример #4
0
 public function testMarshall()
 {
     $th1 = new Th('firstname');
     $th1->setContent(new FlowCollection(array(new TextRun('First Name'))));
     $th1->setAxis('identity');
     $th1->setScope(TableCellScope::COL);
     $th2 = new Th('lastname');
     $th2->setContent(new FlowCollection(array(new TextRun('Last Name'))));
     $th2->setAxis('identity');
     $th2->setScope(TableCellScope::COL);
     $tr = new Tr(new TableCellCollection(array($th1, $th2)));
     $thead = new Thead(new TrCollection(array($tr)));
     $caption = new Caption();
     $strong = new Strong();
     $strong->setContent(new InlineCollection(array(new TextRun('people'))));
     $caption->setContent(new InlineCollection(array(new TextRun('Some '), $strong, new TextRun(' ...'))));
     $col1 = new Col();
     $col1->setSpan(1);
     $col2 = new Col();
     $col2->setSpan(1);
     $cols = new ColCollection(array($col1, $col2));
     $td1 = new Td();
     $td1->setContent(new FlowCollection(array(new TextRun('John'))));
     $td1->setRowspan(1);
     $td1->setColspan(1);
     $td1->setHeaders(new IdentifierCollection(array('firstname')));
     $td2 = new Td();
     $td2->setContent(new FlowCollection(array(new TextRun('Dunbar Smith Wayson'))));
     $td2->setHeaders(new IdentifierCollection(array('lastname')));
     $td2->setAbbr('Dunbar S.W.');
     $tr1 = new Tr(new TableCellCollection(array($td1, $td2)));
     $td1 = new Td();
     $td1->setContent(new FlowCollection(array(new TextRun('Flash'))));
     $td2 = new Td();
     $td2->setContent(new FlowCollection(array(new TextRun('Gordon'))));
     $tr2 = new Tr(new TableCellCollection(array($td1, $td2)));
     $tbody = new Tbody(new TrCollection(array($tr1, $tr2)));
     $tbodies = new TbodyCollection(array($tbody));
     $table = new Table($tbodies, 'my-table', 'qti table');
     $table->setSummary('Some people...');
     $table->setThead($thead);
     $table->setCaption($caption);
     $table->setCols($cols);
     $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($table);
     $element = $marshaller->marshall($table);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $expected = '<table summary="Some people..." id="my-table" class="qti table">';
     $expected .= '<caption>Some <strong>people</strong> ...</caption>';
     $expected .= '<col/>';
     $expected .= '<col/>';
     $expected .= '<thead>';
     $expected .= '<tr>';
     $expected .= '<th scope="col" axis="identity" id="firstname">First Name</th>';
     $expected .= '<th scope="col" axis="identity" id="lastname">Last Name</th>';
     $expected .= '</tr>';
     $expected .= '</thead>';
     $expected .= '<tbody>';
     $expected .= '<tr>';
     $expected .= '<td headers="firstname" rowspan="1" colspan="1">John</td>';
     $expected .= '<td headers="lastname" abbr="Dunbar S.W.">Dunbar Smith Wayson</td>';
     $expected .= '</tr>';
     $expected .= '<tr>';
     $expected .= '<td>Flash</td>';
     $expected .= '<td>Gordon</td>';
     $expected .= '</tr>';
     $expected .= '</tbody>';
     $expected .= '</table>';
     $this->assertEquals($expected, $dom->saveXML($element));
 }
Пример #5
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));
 }