Foxtrott has submitted this change and it was merged.
Change subject: Adds XmlLayoutFileValidityTest
......................................................................
Adds XmlLayoutFileValidityTest
In case of an issue the test will output something like:
1) Skins\Tests\Chameleon\XmlLayoutFileValidityTest::testXmlValidityOfLayoutFiles
DOMDocument::load(): Opening and ending tag mismatch: component line 10 and
structure in file:///../../layouts/fixedhead.xml, line: 46
Change-Id: I008c5056f6918f97162d2b0cd1911a314237a72b
---
A tests/phpunit/XmlLayoutFileValidityTest.php
1 file changed, 66 insertions(+), 0 deletions(-)
Approvals:
Foxtrott: Verified; Looks good to me, approved
diff --git a/tests/phpunit/XmlLayoutFileValidityTest.php
b/tests/phpunit/XmlLayoutFileValidityTest.php
new file mode 100644
index 0000000..1a89fbb
--- /dev/null
+++ b/tests/phpunit/XmlLayoutFileValidityTest.php
@@ -0,0 +1,66 @@
+<?php
+
+namespace Skins\Tests\Chameleon;
+
+use DOMDocument;
+use RuntimeException;
+
+/**
+ * @ingroup Test
+ *
+ * @group skins-chameleon
+ * @group mediawiki-databaseless
+ *
+ * @licence GNU GPL v3+
+ * @since 1.0
+ *
+ * @author mwjames
+ */
+class XmlLayoutFileValidityTest extends \PHPUnit_Framework_TestCase {
+
+ public function testXmlValidityOfLayoutFiles() {
+
+ $listOfLayoutXmlFiles = $this->loadXmlFiles(
$this->readDirectory( __DIR__ . '/../../layouts' ) );
+
+ $this->assertNotEmpty( $listOfLayoutXmlFiles );
+ $this->assertXmlFiles( $listOfLayoutXmlFiles );
+ }
+
+ protected function assertXmlFiles( $files ) {
+ foreach ( $files as $file ) {
+ $this->assertXmlDocumentLoad( $file );
+ }
+ }
+
+ protected function assertXmlDocumentLoad( $file ) {
+ $document = new DOMDocument();
+ $document->validateOnParse = false;
+ $this->assertTrue( $document->load( $file ) );
+ }
+
+ protected function readDirectory( $path ) {
+
+ $path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR,
$path );
+
+ if ( is_readable( $path ) ) {
+ return $path;
+ }
+
+ throw new RuntimeException( "Expected an accessible {$path}
path" );
+ }
+
+ protected function loadXmlFiles( $path ) {
+
+ $files = array();
+ $directoryIterator = new \RecursiveDirectoryIterator( $path );
+
+ foreach ( new \RecursiveIteratorIterator( $directoryIterator )
as $fileInfo ) {
+ if ( strtolower( substr( $fileInfo->getFilename(), -4 )
) === '.xml' ) {
+ $files[] = $fileInfo->getPathname();
+ }
+ }
+
+ return $files;
+ }
+
+}
--
To view, visit https://gerrit.wikimedia.org/r/125072
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I008c5056f6918f97162d2b0cd1911a314237a72b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/skins/chameleon
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>
Gerrit-Reviewer: Foxtrott <[email protected]>
Gerrit-Reviewer: Mwjames <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits