From: Bartosz DziewoƄski Date: Wed, 17 Feb 2016 19:39:46 +0000 (+0100) Subject: ExportTest: Simplify code that failed on 5.3 because of reserved word 'namespace' X-Git-Tag: 1.31.0-rc.0~7926^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/ajouter.php?a=commitdiff_plain;h=b9903564fac31becd95cdeb381562348a80f0ce4;p=lhc%2Fweb%2Fwiklou.git ExportTest: Simplify code that failed on 5.3 because of reserved word 'namespace' Reserved words, like 'namespace', are perfectly fine now to use as object keys, but it seems they used to not be in PHP 5.3, necessitating workarounds. Change-Id: Iecb79fda19803461dfb3800b8af4d31e971551b8 --- diff --git a/tests/phpunit/includes/ExportTest.php b/tests/phpunit/includes/ExportTest.php index 4a9918ce11..d451e2100d 100644 --- a/tests/phpunit/includes/ExportTest.php +++ b/tests/phpunit/includes/ExportTest.php @@ -43,28 +43,26 @@ class ExportTest extends MediaWikiLangTestCase { /** * Check namespaces match xml - * FIXME: PHP 5.3 support. When we don't support PHP 5.3, - * add ->namespace to object and remove from array */ - $xmlNamespaces = (array) $xmlObject->siteinfo->namespaces; - $xmlNamespaces = str_replace( ' ', '_', $xmlNamespaces['namespace'] ); - unset ( $xmlNamespaces[ '@attributes' ] ); + $xmlNamespaces = (array)$xmlObject->siteinfo->namespaces->namespace; + $xmlNamespaces = str_replace( ' ', '_', $xmlNamespaces ); + unset( $xmlNamespaces[ '@attributes' ] ); foreach ( $xmlNamespaces as &$namespaceObject ) { if ( is_object( $namespaceObject ) ) { $namespaceObject = ''; } } - $actualNamespaces = (array) $wgContLang->getNamespaces(); + $actualNamespaces = (array)$wgContLang->getNamespaces(); $actualNamespaces = array_values( $actualNamespaces ); $this->assertEquals( $actualNamespaces, $xmlNamespaces ); // Check xml page title correct - $xmlTitle = (array) $xmlObject->page->title; + $xmlTitle = (array)$xmlObject->page->title; $this->assertEquals( $pageTitle, $xmlTitle[0] ); // Check xml page text is not empty - $text = (array) $xmlObject->page->revision->text; + $text = (array)$xmlObject->page->revision->text; $this->assertNotEquals( '', $text[0] ); }