From b16590861656557f6a9b43e570b228192ca4a61b Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sun, 27 May 2018 20:36:22 -0700 Subject: [PATCH] Improve ExtensionRegistry test coverage Change-Id: Id1b87e020a220c96b42d86485da67d47b9d565f9 --- tests/phpunit/data/registration/good.json | 10 +++++++++- .../registration/ExtensionRegistryTest.php | 20 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) 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 */ -- 2.20.1