Merge "RevisionStoreDbTestBase, remove redundant needsDB override"
[lhc/web/wiklou.git] / tests / phpunit / includes / Storage / PreMcrSchemaOverride.php
1 <?php
2 namespace MediaWiki\Tests\Storage;
3
4 use Wikimedia\Rdbms\IMaintainableDatabase;
5 use MediaWiki\DB\PatchFileLocation;
6
7 /**
8 * Trait providing schema overrides that allow tests to run against the pre-MCR database schema.
9 */
10 trait PreMcrSchemaOverride {
11
12 use PatchFileLocation;
13 use McrSchemaDetection;
14
15 /**
16 * @return int
17 */
18 protected function getMcrMigrationStage() {
19 return MIGRATION_OLD;
20 }
21
22 /**
23 * @return string[]
24 */
25 protected function getMcrTablesToReset() {
26 return [];
27 }
28
29 /**
30 * @return array[]
31 */
32 protected function getSchemaOverrides( IMaintainableDatabase $db ) {
33 $overrides = [
34 'scripts' => [],
35 'drop' => [],
36 'create' => [],
37 'alter' => [],
38 ];
39
40 if ( $this->hasMcrTables( $db ) ) {
41 $overrides['drop'] = [ 'slots', 'content', 'slot_roles', 'content_models', ];
42 $overrides['scripts'][] = $this->getSqlPatchPath( $db, '/drop-mcr-tables', __DIR__ );
43 }
44
45 if ( !$this->hasPreMcrFields( $db ) ) {
46 $overrides['alter'][] = 'revision';
47 $overrides['scripts'][] = $this->getSqlPatchPath( $db, '/create-pre-mcr-fields', __DIR__ );
48 }
49
50 return $overrides;
51 }
52
53 }