Merge "maintenance: Script to rename titles for Unicode uppercasing changes"
[lhc/web/wiklou.git] / tests / phpunit / includes / Revision / McrReadNewSchemaOverride.php
1 <?php
2
3 namespace MediaWiki\Tests\Revision;
4
5 use Wikimedia\Rdbms\IMaintainableDatabase;
6 use MediaWiki\DB\PatchFileLocation;
7
8 /**
9 * Trait providing schema overrides that allow tests to run against the intermediate MCR database
10 * schema for use during schema migration.
11 */
12 trait McrReadNewSchemaOverride {
13
14 use PatchFileLocation;
15 use McrSchemaDetection;
16
17 /**
18 * @return int
19 */
20 protected function getMcrMigrationStage() {
21 return SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW;
22 }
23
24 /**
25 * @return string[]
26 */
27 protected function getMcrTablesToReset() {
28 return [ 'content', 'content_models', 'slots', 'slot_roles' ];
29 }
30
31 /**
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 }