Merge "Improve ExtensionRegistry test coverage"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 29 May 2018 17:18:20 +0000 (17:18 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 29 May 2018 17:18:20 +0000 (17:18 +0000)
tests/phpunit/data/registration/good.json
tests/phpunit/includes/registration/ExtensionRegistryTest.php

index ad16c5e..cfad069 100644 (file)
@@ -1,4 +1,12 @@
 {
        "name": "FooBar",
-       "manifest_version": 1
+       "attributes": {
+               "FooBar": {
+                       "Attr": [ "test" ]
+               },
+               "NotLoaded": {
+                       "Attr": [ "test2" ]
+               }
+       },
+       "manifest_version": 2
 }
index 67bc088..a372c8c 100644 (file)
@@ -51,6 +51,26 @@ class ExtensionRegistryTest extends MediaWikiTestCase {
                $registry->loadFromQueue();
        }
 
+       public function testLoadFromQueue() {
+               $registry = new ExtensionRegistry();
+               $registry->queue( "{$this->dataDir}/good.json" );
+               $registry->loadFromQueue();
+               $this->assertArrayHasKey( 'FooBar', $registry->getAllThings() );
+               $this->assertTrue( $registry->isLoaded( 'FooBar' ) );
+               $this->assertSame( [ 'test' ], $registry->getAttribute( 'FooBarAttr' ) );
+               $this->assertSame( [], $registry->getAttribute( 'NotLoadedAttr' ) );
+       }
+
+       /**
+        * @expectedException PHPUnit_Framework_Error
+        */
+       public function testReadFromQueue_nonexistent() {
+               $registry = new ExtensionRegistry();
+               $registry->readFromQueue( [
+                       __DIR__ . '/doesnotexist.json' => 1
+               ] );
+       }
+
        /**
         * @dataProvider provideExportExtractedDataGlobals
         */