From: Kunal Mehta Date: Mon, 28 May 2018 03:36:22 +0000 (-0700) Subject: Improve ExtensionRegistry test coverage X-Git-Tag: 1.34.0-rc.0~5267^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=b16590861656557f6a9b43e570b228192ca4a61b;p=lhc%2Fweb%2Fwiklou.git Improve ExtensionRegistry test coverage Change-Id: Id1b87e020a220c96b42d86485da67d47b9d565f9 --- diff --git a/tests/phpunit/data/registration/good.json b/tests/phpunit/data/registration/good.json index ad16c5e452..cfad069c17 100644 --- a/tests/phpunit/data/registration/good.json +++ b/tests/phpunit/data/registration/good.json @@ -1,4 +1,12 @@ { "name": "FooBar", - "manifest_version": 1 + "attributes": { + "FooBar": { + "Attr": [ "test" ] + }, + "NotLoaded": { + "Attr": [ "test2" ] + } + }, + "manifest_version": 2 } diff --git a/tests/phpunit/includes/registration/ExtensionRegistryTest.php b/tests/phpunit/includes/registration/ExtensionRegistryTest.php index 67bc088d78..a372c8c26d 100644 --- a/tests/phpunit/includes/registration/ExtensionRegistryTest.php +++ b/tests/phpunit/includes/registration/ExtensionRegistryTest.php @@ -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 */