aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/structure/AbstractSchemaValidationTest.php
diff options
context:
space:
mode:
authorDaimona Eaytoy <daimona.wiki@gmail.com>2024-12-11 16:16:57 +0100
committerDaimona Eaytoy <daimona.wiki@gmail.com>2024-12-14 04:30:30 +0100
commit648ae4d2fbafd76c826bfb487918d614a01bf396 (patch)
treee2e09a5a2f619c048c64675f128b775df1cc8f27 /tests/phpunit/structure/AbstractSchemaValidationTest.php
parent263b069c7f2bb6f9bc866a06ef083224733bbe5e (diff)
downloadmediawikicore-648ae4d2fbafd76c826bfb487918d614a01bf396.tar.gz
mediawikicore-648ae4d2fbafd76c826bfb487918d614a01bf396.zip
tests: Add structure test for content of abstract schema changes
- Rename AbstractSchemaValidationTest to AbstractSchemaTest, as we're no longer testing validation only. - Namespace the test and make it extend MediaWikiIntegrationTestCase. - Check that the autogenerated content from each JSON file matches what's in the source tree. For the main schema file, this was done in DatabaseIntegrationTest, so remove it from there. - Whitespace differences are ignored to make future changes easier. - Use separate methods for testing the main schema and schema changes. - Add static methods to provide the SQL paths. The plan is to move this logic to an abstract class, where these will be abstract methods. Bug: T381981 Change-Id: I23bc92da73a5969bb7eb79f2598120d6aa4c41ac
Diffstat (limited to 'tests/phpunit/structure/AbstractSchemaValidationTest.php')
-rw-r--r--tests/phpunit/structure/AbstractSchemaValidationTest.php63
1 files changed, 0 insertions, 63 deletions
diff --git a/tests/phpunit/structure/AbstractSchemaValidationTest.php b/tests/phpunit/structure/AbstractSchemaValidationTest.php
deleted file mode 100644
index 7428c40278f5..000000000000
--- a/tests/phpunit/structure/AbstractSchemaValidationTest.php
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-/**
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-use MediaWiki\DB\AbstractSchemaValidationError;
-use MediaWiki\DB\AbstractSchemaValidator;
-
-/**
- * Validates all abstract schemas against the abstract-schema schemas in the docs/ folder.
- * @coversNothing
- */
-class AbstractSchemaValidationTest extends PHPUnit\Framework\TestCase {
- use MediaWikiCoversValidator;
-
- /**
- * @var AbstractSchemaValidator
- */
- protected $validator;
-
- protected function setUp(): void {
- parent::setUp();
-
- $this->validator = new AbstractSchemaValidator();
- }
-
- public static function provideSchemas(): Generator {
- yield 'sql/tables.json' => [ __DIR__ . '/../../../sql/tables.json' ];
-
- foreach ( glob( __DIR__ . '/../../../sql/abstractSchemaChanges/*.json' ) as $schemaChange ) {
- $fileName = pathinfo( $schemaChange, PATHINFO_BASENAME );
-
- yield $fileName => [ $schemaChange ];
- }
- }
-
- /**
- * @dataProvider provideSchemas
- * @param string $path Path to tables.json file
- */
- public function testSchemasPassValidation( string $path ): void {
- try {
- $this->validator->validate( $path );
- // All good
- $this->assertTrue( true );
- } catch ( AbstractSchemaValidationError $e ) {
- $this->fail( $e->getMessage() );
- }
- }
-}