Merge "Fix 'Tags' padding to keep it farther from the edge and document the source...
[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 * @override MediaWikiTestCase::getSchemaOverrides
31 * @return array[]
32 */
33 protected function getSchemaOverrides( IMaintainableDatabase $db ) {
34 $overrides = [
35 'scripts' => [],
36 'drop' => [],
37 'create' => [],
38 'alter' => [],
39 ];
40
41 if ( $this->hasMcrTables( $db ) ) {
42 $overrides['drop'] = [ 'slots', 'content', 'slot_roles', 'content_models', ];
43 $overrides['scripts'][] = $this->getSqlPatchPath( $db, '/drop-mcr-tables', __DIR__ );
44 }
45
46 if ( !$this->hasPreMcrFields( $db ) ) {
47 $overrides['alter'][] = 'revision';
48 $overrides['scripts'][] = $this->getSqlPatchPath( $db, '/create-pre-mcr-fields', __DIR__ );
49 }
50
51 return $overrides;
52 }
53
54 }