Merge "Title: Use directly Language::factory instead of wfGetLangObj"
[lhc/web/wiklou.git] / tests / phpunit / includes / Storage / McrWriteBothSchemaOverride.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 intermediate MCR database
9 * schema for use during schema migration.
10 */
11 trait McrWriteBothSchemaOverride {
12
13 use PatchFileLocation;
14 use McrSchemaDetection;
15
16 /**
17 * @return int
18 */
19 protected function getMcrMigrationStage() {
20 return MIGRATION_WRITE_BOTH;
21 }
22
23 /**
24 * @return string[]
25 */
26 protected function getMcrTablesToReset() {
27 return [ 'content', 'content_models', 'slots', 'slot_roles' ];
28 }
29
30 /**
31 * @override MediaWikiTestCase::getSchemaOverrides
32 * @return array[]
33 */
34 protected function getSchemaOverrides( IMaintainableDatabase $db ) {
35 $overrides = [
36 'scripts' => [],
37 'drop' => [],
38 'create' => [],
39 'alter' => [],
40 ];
41
42 if ( !$this->hasMcrTables( $db ) ) {
43 $overrides['create'] = [ 'slots', 'content', 'slot_roles', 'content_models', ];
44 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-slot_roles' );
45 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-content_models' );
46 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-content' );
47 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-slots' );
48 }
49
50 if ( !$this->hasPreMcrFields( $db ) ) {
51 $overrides['alter'][] = 'revision';
52 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'create-pre-mcr-fields', __DIR__ );
53 }
54
55 return $overrides;
56 }
57
58 }