Debian Codegraph @

tests/phpunit/maintenance/DumpAsserter.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Tests\Maintenance;
4
5 use LogEntryBase;
6 use PHPUnit\Framework\Assert;
7 use XMLReader;
8
9 /**
10 * Helper for asserting the structure of an XML dump stream.
11 */
12 class DumpAsserter {
13
14 /**
15 * Holds the XMLReader used for analyzing an XML dump
16 *
17 * @var XMLReader|null
18 */
19 protected $xml = null;
20
21 /**
22 * XML dump schema version
23 *
24 * @var string
25 */
26 protected $schemaVersion;
27
28 /**
29 * @var array
30 */
31 private $varMapping = [];
32
33 /**
34 * @param string $schemaVersion see XML_DUMP_SCHEMA_VERSION_XX
35 */
36 public function __construct( $schemaVersion ) {
37 $this->schemaVersion = $schemaVersion;
38 }
39
40 /**
41 * Step the current XML reader until node start of given name is found.
42 *
43 * @param string $name Name of the element to look for
44 * (e.g.: "text" when looking for <text>)
45 *
46 * @param bool $allowAscend Whether the search should continue in parent
47 * nodes of the current position. If false (the default), the search will be aborted
48 * on the next closing element.
49 *
50 * @return bool True if the node could be found. false otherwise.
51 */
52 public function skipToNode( $name, $allowAscend = false ) {
53 $depth = 0;
54 while ( true ) {
55 $current = $this->xml->name;
56 if ( $this->xml->nodeType == XMLReader::ELEMENT ) {
57 if ( $current == $name ) {
58 return true;
59 }
60
61 if ( !$this->xml->isEmptyElement ) {
62 $depth++;
63 }
64 }
65
66 if ( $this->xml->nodeType == XMLReader::END_ELEMENT ) {
67 $depth--;
68 if ( $depth < 0 && !$allowAscend ) {
69 return false;
70 }
71 }
72
73 if ( !$this->xml->read() ) {
74 break;
75 }
76 }
77
78 return false;
79 }
80
81 /**
82 * Step the current XML reader until node start of given name is found,
83 * and advance to the first child node.
84 *
85 * @param string $name Name of the element to look for
86 * (e.g.: "text" when looking for <text>)
87 *
88 * @param bool $allowAscend Whether the search should continue in parent
89 * nodes of the current position. If false (the default), the search will be aborted
90 * on the next closing element.
91 */
92 public function skipIntoNode( $name, $allowAscend = false ) {
93 Assert::assertTrue( $this->skipToNode( $name, $allowAscend ),
94 "Skipping to $name" );
95
96 Assert::assertTrue( !$this->xml->isEmptyElement,
97 "Skipping into $name" );
98
99 $this->xml->read();
100 }
101
102 /**
103 * Step the current XML reader until node end of given name is found.
104 *
105 * @param string $name Name of the closing element to look for
106 * (e.g.: "mediawiki" when looking for </mediawiki>)
107 *
108 * @return bool True if the end node could be found. false otherwise.
109 */
110 public function skipToNodeEnd( $name ) {
111 while ( $this->xml->read() ) {
112 if ( $this->xml->nodeType == XMLReader::END_ELEMENT &&
113 $this->xml->name == $name
114 ) {
115 return true;
116 }
117 }
118
119 return false;
120 }
121
122 /**
123 * Step the current XML reader to the first element start after the node
124 * end of a given name.
125 *
126 * @param string $name Name of the closing element to look for
127 * (e.g.: "mediawiki" when looking for </mediawiki>)
128 *
129 * @return bool True if new element after the closing of $name could be
130 * found. false otherwise.
131 */
132 public function skipPastNodeEnd( $name ) {
133 Assert::assertTrue( $this->skipToNodeEnd( $name ),
134 "Skipping to end of $name" );
135 while ( $this->xml->read() ) {
136 if ( $this->xml->nodeType == XMLReader::ELEMENT ) {
137 return true;
138 }
139 }
140
141 return false;
142 }
143
144 /**
145 * Opens an XML file to analyze.
146 *
147 * @param string $fname Name of file to analyze
148 */
149 public function open( $fname ) {
150 $this->xml = new XMLReader();
151
152 Assert::assertTrue( $this->xml->open( $fname ),
153 "Opening temporary file $fname via XMLReader failed" );
154 }
155
156 /**
157 * Opens an XML file to analyze, verifies the top level tags,
158 * and skips past <siteinfo>.
159 *
160 * The contents of the <siteinfo> tag can be checked if $siteInfoTemplate
161 * is given. See assertDumpHead().
162 *
163 * @param string $fname Name of file to analyze
164 *
165 * @param string|null $siteInfoTemplate
166 * @param string $language
167 */
168 public function assertDumpStart( $fname, $siteInfoTemplate = null, $language = 'en' ) {
169 $this->open( $fname );
170 $this->assertDumpHead( $siteInfoTemplate, $language );
171 }
172
173 /**
174 * Asserts that the head of a dump is valid.
175 * This checks the attributes of the top level <mediawiki> tag.
176 *
177 * If $siteInfoTemplate is given, it is interpreted as the file name
178 * of an XML template that will be used with assertDOM() to check the contents
179 * of the <siteinfo> tag, which is expected to be the first child of
180 * the top level <mediawiki>. Variable substitution applies as defined by
181 * calling setVarMapping().
182 *
183 * After this method returns, the XML reader's position will be after
184 * the closing </siteinfo> tag, before the next tag.
185 *
186 * @param string|null $siteInfoTemplate
187 * @param string $language
188 */
189 public function assertDumpHead( $siteInfoTemplate = null, $language = 'en' ) {
190 $this->assertNodeStart( 'mediawiki', false );
191 $this->assertAttributes( [
192 "xmlns" => "http://www.mediawiki.org/xml/export-{$this->schemaVersion}/",
193 "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
194 "xsi:schemaLocation" => "http://www.mediawiki.org/xml/export-{$this->schemaVersion}/ "
195 . "http://www.mediawiki.org/xml/export-{$this->schemaVersion}.xsd",
196 "version" => "{$this->schemaVersion}",
197 "xml:lang" => "{$language}"
198 ] );
199
200 $this->assertNodeStart( 'siteinfo', false );
201
202 if ( $siteInfoTemplate ) {
203 // Checking site info
204 $this->assertDOM( $siteInfoTemplate );
205 }
206
207 // skip past extra namespaces
208 $this->skipPastNodeEnd( 'siteinfo' );
209 }
210
211 /**
212 * Asserts that the xml reader is at the final closing tag of an xml file and
213 * closes the reader.
214 *
215 * @param string $name (optional) the name of the final tag
216 * (e.g.: "mediawiki" for </mediawiki>)
217 */
218 public function assertDumpEnd( $name = "mediawiki" ) {
219 $this->assertNodeEnd( $name, false );
220 if ( $this->xml->read() ) {
221 $this->skipWhitespace();
222 }
223 Assert::assertEquals( $this->xml->nodeType, XMLReader::NONE,
224 "No proper entity left to parse" );
225 $this->close();
226 }
227
228 public function close() {
229 $this->xml->close();
230 }
231
232 /**
233 * Steps the xml reader over white space
234 */
235 public function skipWhitespace() {
236 $cont = true;
237 while ( $cont && ( ( $this->xml->nodeType == XMLReader::NONE )
238 || ( $this->xml->nodeType == XMLReader::WHITESPACE )
239 || ( $this->xml->nodeType == XMLReader::SIGNIFICANT_WHITESPACE ) ) ) {
240 $cont = $this->xml->read();
241 }
242 }
243
244 /**
245 * Asserts that the xml reader is at an element of given name, and optionally
246 * skips past it. If the reader is at a whitespace element, the whitespace is
247 * skipped first.
248 *
249 * @param string $name The name of the element to check for
250 * (e.g.: "mediawiki" for <mediawiki>)
251 * @param bool $skip (optional) if true, skip past the found element
252 */
253 public function assertNodeStart( $name, $skip = true ) {
254 $this->skipWhitespace();
255 Assert::assertEquals( $name, $this->xml->name, "Node name" );
256 Assert::assertEquals( XMLReader::ELEMENT, $this->xml->nodeType, "Node type" );
257 if ( $skip ) {
258 Assert::assertTrue( $this->xml->read(), "Skipping past start tag" );
259 }
260 }
261
262 /**
263 * Asserts that the XML reader is at an element start, and that the element
264 * has the given attributes with the given values.
265 * Variable substitution applies for variables set via setVarMapping().
266 *
267 * @param array $attributes
268 * @param bool $skip (optional) if true, skip past the found element
269 */
270 public function assertAttributes( $attributes, $skip = true ) {
271 Assert::assertEquals( XMLReader::ELEMENT, $this->xml->nodeType, "Node type" );
272 $actualAttributes = $this->getAttributeArray( $this->xml );
273
274 $attributes = array_map(
275 function ( $v ) {
276 return $this->resolveVars( $v );
277 },
278 $attributes
279 );
280 $actualAttributes = array_intersect_key( $actualAttributes, $attributes );
281
282 Assert::assertEquals( $attributes, $actualAttributes, "Attributes" );
283
284 if ( $skip ) {
285 Assert::assertTrue( $this->xml->read(), "Skipping past start tag" );
286 }
287 }
288
289 /**
290 * Asserts that the xml reader is at an element of given name, and that element
291 * is an empty tag.
292 *
293 * @param string $name The name of the element to check for
294 * (e.g.: "text" for <text/>)
295 * @param bool $skip (optional) if true, skip past the found element
296 * @param bool $skip_ws (optional) if true, also skip past white spaces that trail the
297 * closing element.
298 */
299 public function assertEmptyNode( $name, $skip = true, $skip_ws = true ) {
300 $this->assertNodeStart( $name, false );
301 Assert::assertFalse( !$this->xml->isEmptyElement, "$name tag has content" );
302
303 if ( $skip ) {
304 Assert::assertTrue( $this->xml->read(), "Skipping $name tag" );
305 if ( ( $this->xml->nodeType == XMLReader::END_ELEMENT )
306 && ( $this->xml->name == $name )
307 ) {
308 $this->xml->read();
309 }
310
311 if ( $skip_ws ) {
312 $this->skipWhitespace();
313 }
314 }
315 }
316
317 /**
318 * Asserts that the xml reader is at a closing element of given name, and optionally
319 * skips past it. If the reader is at a whitespace element, the whitespace is
320 * skipped first.
321 *
322 * @param string $name The name of the closing element to check for
323 * (e.g.: "mediawiki" for </mediawiki>)
324 * @param bool $skip (optional) if true, skip past the found element
325 */
326 public function assertNodeEnd( $name, $skip = true ) {
327 $this->skipWhitespace();
328 Assert::assertEquals( $name, $this->xml->name, "Node name" );
329 Assert::assertEquals( XMLReader::END_ELEMENT, $this->xml->nodeType, "Node type" );
330 if ( $skip ) {
331 // note: if there is no more content after the tag and read() returns false,
332 // that's fine.
333 $this->xml->read();
334 }
335 }
336
337 /**
338 * Asserts that the xml reader is at an element of given tag that contains a given text,
339 * and skips over the element.
340 *
341 * @param string $name The name of the element to check for
342 * (e.g.: "mediawiki" for <mediawiki>...</mediawiki>)
343 * @param string|bool $text If string, check if it equals the elements text.
344 * Variable substitution applies. If false, ignore the element's text.
345 * @param bool $skip_ws (optional) if true, skip past white spaces that trail the
346 * closing element.
347 */
348 public function assertTextNode( $name, $text, $skip_ws = true ) {
349 $this->assertNodeStart( $name );
350
351 if ( $text !== false ) {
352 $text = $this->resolveVars( $text );
353 $actual = $this->resolveVars( $this->xml->value );
354 Assert::assertEquals( $text, $actual, "Text of node " . $name );
355 }
356 Assert::assertTrue( $this->xml->read(), "Skipping past processed text of " . $name );
357 $this->assertNodeEnd( $name );
358
359 if ( $skip_ws ) {
360 $this->skipWhitespace();
361 }
362 }
363
364 /**
365 * Asserts that the xml reader is at the start of a page element and skips over the first
366 * tags, after checking them.
367 *
368 * Besides the opening page element, this function also checks for and skips over the
369 * title, ns, and id tags. Hence after this function, the xml reader is at the first
370 * revision of the current page.
371 *
372 * @param int $id Id of the page to assert
373 * @param int $ns Number of namespage to assert
374 * @param string $name Title of the current page
375 */
376 public function assertPageStart( $id, $ns, $name ) {
377 $this->assertNodeStart( "page" );
378 $this->assertTextNode( "title", $name );
379 $this->assertTextNode( "ns", $ns );
380 $this->assertTextNode( "id", $id );
381 }
382
383 /**
384 * Asserts that the xml reader is at the page's closing element and skips to the next
385 * element.
386 */
387 public function assertPageEnd() {
388 $this->assertNodeEnd( "page" );
389 }
390
391 /**
392 * Checks and skips tags that represent the properties of a revision.
393 *
394 * @param int $id Id of the revision
395 * @param string $summary Summary of the revision
396 * @param string $text_sha1 The base36 SHA-1 of the revision's text
397 * @param string $hasEarlyText Whether a text tag is expected before the <sha1> tag.
398 * Must be one of 'yes', 'no', or maybe.
399 * @param int|bool $parentid (optional) id of the parent revision
400 * @param string $model The expected content model id (default: CONTENT_MODEL_WIKITEXT)
401 * @param string $format The expected format model id (default: CONTENT_FORMAT_WIKITEXT)
402 * @param bool &$foundText Output, whether a text tag was found before the SHA1 tag.
403 * If this returns false, the text tag should be the next tag after the method returns.
404 */
405 public function assertRevisionProperties( $id, $summary,
406 $text_sha1, $hasEarlyText = 'maybe', $parentid = false,
407 $model = CONTENT_MODEL_WIKITEXT, $format = CONTENT_FORMAT_WIKITEXT,
408 &$foundText = ''
409 ) {
410 $this->assertTextNode( "id", $id );
411 if ( $parentid !== false ) {
412 $this->assertTextNode( "parentid", $parentid );
413 }
414 $this->assertTextNode( "timestamp", false );
415
416 $this->assertNodeStart( "contributor" );
417 $this->assertTextNode( "username", false );
418 $this->assertTextNode( "id", false );
419 $this->assertNodeEnd( "contributor" );
420
421 $this->assertTextNode( "comment", $summary );
422
423 if ( $this->schemaVersion >= XML_DUMP_SCHEMA_VERSION_11 ) {
424 $this->assertTextNode( "origin", false );
425 }
426
427 $this->assertTextNode( "model", $model );
428
429 $this->assertTextNode( "format", $format );
430
431 if ( $hasEarlyText === 'yes' || ( $this->xml->name == "text" && $hasEarlyText === 'maybe' ) ) {
432 $foundText = true;
433 $this->assertNodeStart( "text", false );
434 $this->xml->next();
435 $this->skipWhitespace();
436 } else {
437 $foundText = false;
438 }
439
440 if ( $text_sha1 ) {
441 $this->assertTextNode( "sha1", $text_sha1 );
442 } else {
443 $this->assertEmptyNode( "sha1" );
444 }
445 }
446
447 /**
448 * Asserts that the xml reader is at a revision and checks its representation before
449 * skipping over it.
450 *
451 * @param int $id Id of the revision
452 * @param string $summary Summary of the revision
453 * @param int $text_id Id of the revision's text
454 * @param int $text_bytes Number of bytes in the revision's text
455 * @param string $text_sha1 The base36 SHA-1 of the revision's text
456 * @param string|bool $text (optional) The revision's string, or false to check for a
457 * revision stub
458 * @param int|bool $parentid (optional) id of the parent revision
459 * @param string $model The expected content model id (default: CONTENT_MODEL_WIKITEXT)
460 * @param string $format The expected format model id (default: CONTENT_FORMAT_WIKITEXT)
461 */
462 public function assertRevision( $id, $summary, $text_id, $text_bytes,
463 $text_sha1, $text = false, $parentid = false,
464 $model = CONTENT_MODEL_WIKITEXT, $format = CONTENT_FORMAT_WIKITEXT
465 ) {
466 $this->assertNodeStart( "revision" );
467
468 $this->assertRevisionProperties(
469 $id,
470 $summary,
471 $text_sha1,
472 'maybe',
473 $parentid,
474 $model,
475 $format,
476 $text_found
477 );
478
479 if ( !$text_found ) {
480 $this->assertText( $id, $text_id, $text_bytes, $text );
481 }
482
483 $this->assertNodeEnd( "revision" );
484 $this->skipWhitespace();
485 }
486
487 public function assertText( $id, $text_id, $text_bytes, $text ) {
488 $this->assertNodeStart( "text", false );
489 if ( $text_bytes !== false ) {
490 Assert::assertEquals( $this->xml->getAttribute( "bytes" ), $text_bytes,
491 "Attribute 'bytes' of revision " . $id );
492 }
493
494 if ( $text === false ) {
495 Assert::assertEquals( $this->xml->getAttribute( "id" ), $text_id,
496 "Text id of revision " . $id );
497 Assert::assertNull( $this->xml->getAttribute( "xml:space" ),
498 "xml:space attribute shout not be present" );
499 $this->assertEmptyNode( "text" );
500 } else {
501 // Testing for a real dump
502 Assert::assertEquals( $this->xml->getAttribute( "xml:space" ), "preserve",
503 "xml:space=preserve should be present" );
504 Assert::assertTrue( $this->xml->read(), "Skipping text start tag" );
505 Assert::assertEquals( $text, $this->xml->value, "Text of revision " . $id );
506 Assert::assertTrue( $this->xml->read(), "Skipping past text" );
507 $this->assertNodeEnd( "text" );
508 $this->skipWhitespace();
509 }
510 }
511
512 /**
513 * asserts that the xml reader is at the beginning of a log entry and skips over
514 * it while analyzing it.
515 *
516 * @param int $id Id of the log entry
517 * @param string $user_name User name of the log entry's performer
518 * @param int $user_id User id of the log entry 's performer
519 * @param string|null $comment Comment of the log entry. If null, the comment text is ignored.
520 * @param string $type Type of the log entry
521 * @param string $subtype Subtype of the log entry
522 * @param string $title Title of the log entry's target
523 * @param array $parameters (optional) unserialized data accompanying the log entry
524 */
525 public function assertLogItem( $id, $user_name, $user_id, $comment, $type,
526 $subtype, $title, $parameters = []
527 ) {
528 $this->assertNodeStart( "logitem" );
529
530 $this->assertTextNode( "id", $id );
531 $this->assertTextNode( "timestamp", false );
532
533 $this->assertNodeStart( "contributor" );
534 $this->assertTextNode( "username", $user_name );
535 $this->assertTextNode( "id", $user_id );
536 $this->assertNodeEnd( "contributor" );
537
538 if ( $comment !== null ) {
539 $this->assertTextNode( "comment", $comment );
540 }
541 $this->assertTextNode( "type", $type );
542 $this->assertTextNode( "action", $subtype );
543 $this->assertTextNode( "logtitle", $title );
544
545 $this->assertNodeStart( "params" );
546 $parameters_xml = LogEntryBase::extractParams( $this->xml->value, "$type/$subtype" );
547 Assert::assertEquals( $parameters, $parameters_xml );
548 Assert::assertTrue( $this->xml->read(), "Skipping past processed text of params" );
549 $this->assertNodeEnd( "params" );
550
551 $this->assertNodeEnd( "logitem" );
552 }
553
554 /**
555 * Returns the XMLReader's current line number for reporting.
556 *
557 * @param XMLReader|null $xml
558 *
559 * @return int
560 */
561 public function getLineNumber( ?XMLReader $xml = null ) {
562 $xml ??= $this->xml;
563
564 if ( $xml->nodeType == XMLReader::NONE ) {
565 return 0;
566 }
567
568 return $xml->expand()->getLineNo();
569 }
570
571 /**
572 * Opens an XML template file and compares it to the XML structure at the current position of
573 * this asserter.
574 *
575 * If the outer-most tag of the template file is <test:data>, that tag is
576 * ignored during comparison. This allows template files to contain arbitrary snippets of XML.
577 * When the tag <test:end/> is encountered in the template, the comparison is ended.
578 * This allows template files to be written to match the beginning of a structure,
579 * without the need for subsequent contents to match.
580 *
581 * The contents of $file are subject to variable substitution based on
582 * the values provided via setVarMapping().
583 *
584 * @param string $file Name of file to analyze
585 */
586 public function assertDOM( $file ) {
587 $exXml = new XMLReader();
588
589 Assert::assertTrue( $exXml->open( $file ),
590 "Opening fixture file $file via XMLReader failed" );
591
592 $line = 0;
593 while ( true ) {
594 $line = max( $line, $this->getLineNumber( $exXml ) );
595 $location = "[$file line $line] ";
596
597 while ( $exXml->nodeType == XMLReader::NONE
598 || $exXml->nodeType == XMLReader::WHITESPACE
599 || $exXml->nodeType == XMLReader::SIGNIFICANT_WHITESPACE
600 || $exXml->nodeType == XMLReader::COMMENT
601 || ( $exXml->nodeType == XMLReader::ELEMENT && $exXml->name === 'test:data' ) ) {
602
603 // Reached the end of the template file, so we are done here.
604 if ( !$exXml->read() ) {
605 break 2;
606 }
607
608 // Reached the end of the test data, so we are done here.
609 if ( $exXml->nodeType == XMLReader::END_ELEMENT && $exXml->name === 'test:data' ) {
610 break 2;
611 }
612 }
613
614 while ( $this->xml->nodeType == XMLReader::NONE
615 || $this->xml->nodeType == XMLReader::WHITESPACE
616 || $this->xml->nodeType == XMLReader::SIGNIFICANT_WHITESPACE
617 || $this->xml->nodeType == XMLReader::COMMENT ) {
618 Assert::assertTrue( $this->xml->read(), $location . 'Document ended unexpectedly' );
619 }
620
621 // End comparison early, ignore the rest of the contents of the template file.
622 if ( $exXml->nodeType == XMLReader::ELEMENT && $exXml->name === 'test:end' ) {
623 break;
624 }
625
626 $line = max( $line, $this->getLineNumber( $exXml ) );
627 $location = "[$file line $line] ";
628
629 Assert::assertSame( $exXml->nodeType, $this->xml->nodeType, $location . 'Node type' );
630 Assert::assertSame( $exXml->name, $this->xml->name, $location . 'Node type' );
631 Assert::assertSame(
632 $exXml->hasValue,
633 $this->xml->hasValue,
634 $location . 'Node has value?'
635 );
636 Assert::assertSame(
637 $exXml->hasAttributes,
638 $this->xml->hasAttributes,
639 $location . 'Node has attributes?'
640 );
641
642 if ( $exXml->hasValue ) {
643 $expValue = $this->resolveVars( $exXml->value );
644 $actValue = $this->resolveVars( $this->xml->value );
645 Assert::assertSame( $expValue, $actValue, $location . 'Node value' );
646 }
647
648 if ( $exXml->hasAttributes ) {
649 $expectedAttributes = $this->getAttributeArray( $exXml );
650 $actualAttributes = $this->getAttributeArray( $this->xml );
651
652 Assert::assertEquals( $expectedAttributes, $actualAttributes, $location . 'Attributes' );
653 }
654
655 // Reached the end of the template file, so we are done here.
656 if ( !$exXml->read() ) {
657 break;
658 }
659
660 // Reached the end of the test data, so we are done here.
661 if ( $exXml->nodeType == XMLReader::END_ELEMENT && $exXml->name === 'test:data' ) {
662 break;
663 }
664
665 Assert::assertTrue( $this->xml->read(), $location . 'Document ended unexpectedly' );
666 }
667
668 $exXml->close();
669 }
670
671 /**
672 * Strip any <test:...> tags from a string.
673 *
674 * @param string $text
675 *
676 * @return string
677 */
678 public function stripTestTags( $text ) {
679 $text = preg_replace( '@<!--.*?-->@s', '', $text );
680 $text = preg_replace( '@</?test:[^>]+>@', '', $text );
681 return $text;
682 }
683
684 private function getAttributeArray( ?XMLReader $xml = null ) {
685 if ( !$xml ) {
686 $xml = $this->xml;
687 }
688
689 if ( $xml->nodeType !== XMLReader::ELEMENT ) {
690 return null;
691 }
692
693 if ( !$xml->hasAttributes ) {
694 return [];
695 }
696
697 $attr = [];
698 while ( $xml->moveToNextAttribute() ) {
699 $attr[$xml->name] = $this->resolveVars( $xml->value );
700 }
701
702 return $attr;
703 }
704
705 /**
706 * @param string $text
707 *
708 * @return string
709 */
710 public function resolveVars( $text ) {
711 return str_replace(
712 array_keys( $this->varMapping ),
713 array_values( $this->varMapping ),
714 $text
715 );
716 }
717
718 /**
719 * Define a variable mapping to be applied by assertDOM
720 *
721 * @param string $name
722 * @param string $value
723 */
724 public function setVarMapping( $name, $value ) {
725 $key = '{{' . $name . '}}';
726 $this->varMapping[$key] = $value;
727 }
728
729 /**
730 * @return string
731 */
732 public function getSchemaVersion() {
733 return $this->schemaVersion;
734 }
735
736 }