Merge "(bug 37755) Set robot meta tags for 'view source' pages"
[lhc/web/wiklou.git] / tests / phpunit / docs / ExportDemoTest.php
1 <?php
2 /**
3 * Test for the demo xml
4 *
5 * @group Dump
6 */
7 class ExportDemoTest extends DumpTestCase {
8
9 /**
10 * @group large
11 */
12 function testExportDemo() {
13 $this->validateXmlFileAgainstXsd( "../../docs/export-demo.xml" );
14 }
15
16 /**
17 * Validates a xml file against the xsd.
18 *
19 * The validation is slow, because php has to read the xsd on each call.
20 *
21 * @param $fname string: name of file to validate
22 */
23 protected function validateXmlFileAgainstXsd( $fname ) {
24 $version = WikiExporter::schemaVersion();
25
26 $dom = new DomDocument();
27 $dom->load( $fname );
28
29 // Ensure, the demo is for the current version
30 $this->assertEquals( $dom->documentElement->getAttribute( 'version' ), $version, 'export-demo.xml should have the current version' );
31
32 try {
33 $this->assertTrue( $dom->schemaValidate( "../../docs/export-" . $version . ".xsd" ),
34 "schemaValidate has found an error" );
35 } catch( Exception $e ) {
36 $this->fail( "xml not valid against xsd: " . $e->getMessage() );
37 }
38 }
39 }