diff options
author | Petr Pchelko <ppchelko@wikimedia.org> | 2021-11-29 12:48:32 -0800 |
---|---|---|
committer | Petr Pchelko <ppchelko@wikimedia.org> | 2022-02-09 07:09:32 -0800 |
commit | ef73bfafd98f1a16c82fdf97a2ed46b0075e5bd3 (patch) | |
tree | c5d911c1be0683deceb2652753b19c6424b8d5c4 /tests/phpunit/structure/SettingsTest.php | |
parent | 6fe77549d776a2b5c80840d58838c7fcb5491960 (diff) | |
download | mediawikicore-ef73bfafd98f1a16c82fdf97a2ed46b0075e5bd3.tar.gz mediawikicore-ef73bfafd98f1a16c82fdf97a2ed46b0075e5bd3.zip |
Add simple configuration doc generator
This is a first draft of the configuration doc renderer.
The resulting markdown certainly needs some love, but
we can work on improvements incrementally. This gives
us a baseline to reference on doc.wikimedia.org
Bug: T296647
Change-Id: I3c426b9fc37b1cf7ce8423969b2d7589767ee6cc
Diffstat (limited to 'tests/phpunit/structure/SettingsTest.php')
-rw-r--r-- | tests/phpunit/structure/SettingsTest.php | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/tests/phpunit/structure/SettingsTest.php b/tests/phpunit/structure/SettingsTest.php index 4b20ed6105a4..890fa4bd8264 100644 --- a/tests/phpunit/structure/SettingsTest.php +++ b/tests/phpunit/structure/SettingsTest.php @@ -42,10 +42,10 @@ class SettingsTest extends MediaWikiIntegrationTestCase { new ArrayConfigBuilder(), $this->createNoOpMock( PhpIniSink::class ) ); - $result = $settingsBuilder->loadFile( 'includes/config-schema.yaml' ) + $validationResult = $settingsBuilder->loadFile( 'includes/config-schema.yaml' ) ->apply() ->validate(); - $this->assertArrayEquals( [], $result->getErrors() ); + $this->assertArrayEquals( [], $validationResult->getErrors() ); } /** @@ -57,19 +57,28 @@ class SettingsTest extends MediaWikiIntegrationTestCase { $this->assertTrue( $result->isGood(), $result->__toString() ); } - public function testConfigSchemaPhpGenerated() { - $schemaGenerator = Shell::makeScriptCommand( - __DIR__ . '/../../../maintenance/generateConfigSchema.php', - [ '--output', 'php://stdout' ] - ); + public function provideConfigGeneration() { + yield 'docs/Configuration.md' => [ + 'script' => __DIR__ . '/../../../maintenance/generateConfigDoc.php', + 'expectedFile' => __DIR__ . '/../../../docs/Configuration.md', + ]; + yield 'incl/Configuration.md' => [ + 'script' => __DIR__ . '/../../../maintenance/generateConfigSchema.php', + 'expectedFile' => __DIR__ . '/../../../includes/config-schema.php', + ]; + } + + /** + * @dataProvider provideConfigGeneration + */ + public function testConfigGeneration( string $script, string $expectedFile ) { + $schemaGenerator = Shell::makeScriptCommand( $script, [ '--output', 'php://stdout' ] ); $result = $schemaGenerator->execute(); - $this->assertSame( 0, $result->getExitCode(), 'Config doc generation must finish successfully' ); - $this->assertSame( '', $result->getStderr(), 'Config doc generation must not have errors' ); + $this->assertSame( 0, $result->getExitCode(), 'Config generation must finish successfully' ); + $this->assertSame( '', $result->getStderr(), 'Config generation must not have errors' ); - $oldGeneratedSchema = file_get_contents( - __DIR__ . '/../../../includes/config-schema.php' - ); + $oldGeneratedSchema = file_get_contents( $expectedFile ); $this->assertEquals( $oldGeneratedSchema, |