Merge "Selenium: replace UserLoginPage with BlankPage where possible"
[lhc/web/wiklou.git] / tests / phpunit / includes / Revision / McrSchemaOverride.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 post-migration
10 * MCR database schema.
11 */
12 trait McrSchemaOverride {
13
14 use PatchFileLocation;
15 use McrSchemaDetection;
16
17 /**
18 * @return int
19 */
20 protected function getMcrMigrationStage() {
21 return MIGRATION_NEW;
22 }
23
24 /**
25 * @return string[]
26 */
27 protected function getMcrTablesToReset() {
28 return [
29 'content',
30 'content_models',
31 'slots',
32 'slot_roles',
33 ];
34 }
35
36 protected function getSchemaOverrides( IMaintainableDatabase $db ) {
37 $overrides = [
38 'scripts' => [],
39 'drop' => [],
40 'create' => [],
41 'alter' => [],
42 ];
43
44 if ( !$this->hasMcrTables( $db ) ) {
45 $overrides['create'] = [ 'slots', 'content', 'slot_roles', 'content_models', ];
46 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-slot_roles' );
47 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-content_models' );
48 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-content' );
49 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'patch-slots' );
50 }
51
52 if ( !$this->hasPreMcrFields( $db ) ) {
53 $overrides['alter'][] = 'revision';
54 $overrides['scripts'][] = $this->getSqlPatchPath( $db, 'drop-pre-mcr-fields', __DIR__ );
55 }
56
57 return $overrides;
58 }
59
60 }