Work around change in SimpleXMLElement behavior introduced in PHP 7.3.17
[lhc/web/wiklou.git] / tests / phpunit / includes / ExportTest.php
index a5d3570..e17479a 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Test class for Export methods.
  *
@@ -20,7 +22,6 @@ class ExportTest extends MediaWikiLangTestCase {
         * @covers WikiExporter::pageByTitle
         */
        public function testPageByTitle() {
-               global $wgContLang;
                $pageTitle = 'UTPage';
 
                $exporter = new WikiExporter(
@@ -42,16 +43,14 @@ class ExportTest extends MediaWikiLangTestCase {
                /**
                 * Check namespaces match xml
                 */
-               $xmlNamespaces = (array)$xmlObject->siteinfo->namespaces->namespace;
-               $xmlNamespaces = str_replace( ' ', '_', $xmlNamespaces );
-               unset( $xmlNamespaces[ '@attributes' ] );
-               foreach ( $xmlNamespaces as &$namespaceObject ) {
-                       if ( is_object( $namespaceObject ) ) {
-                               $namespaceObject = '';
-                       }
+               foreach ( $xmlObject->siteinfo->namespaces->children() as $namespace ) {
+                       // Get the text content of the SimpleXMLElement
+                       $xmlNamespaces[] = (string)$namespace;
                }
+               $xmlNamespaces = str_replace( ' ', '_', $xmlNamespaces );
 
-               $actualNamespaces = (array)$wgContLang->getNamespaces();
+               $actualNamespaces = (array)MediaWikiServices::getInstance()->getContentLanguage()->
+                       getNamespaces();
                $actualNamespaces = array_values( $actualNamespaces );
                $this->assertEquals( $actualNamespaces, $xmlNamespaces );