X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FActorMigrationTest.php;h=de70f261e47ebbb627a59a3a9d346c8aab3c2ff3;hb=214b37ff07f3fde89430297b2a857750a56ae205;hp=1f2b13cfa82043a3a93d69b67c38f2c9f914aa5c;hpb=962b690e92a258bd53100e976dc5575180696bf0;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/ActorMigrationTest.php b/tests/phpunit/includes/ActorMigrationTest.php index 1f2b13cfa8..de70f261e4 100644 --- a/tests/phpunit/includes/ActorMigrationTest.php +++ b/tests/phpunit/includes/ActorMigrationTest.php @@ -658,14 +658,18 @@ class ActorMigrationTest extends MediaWikiLangTestCase { $callback( 1, [] ); } - public function testInsertUserIdentity() { + /** + * @dataProvider provideStages + * @param int $stage + */ + public function testInsertUserIdentity( $stage ) { $this->setMwGlobals( [ // for User::getActorId() - 'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_OLD + 'wgActorTableSchemaMigrationStage' => $stage ] ); $this->overrideMwServices(); - $user = $this->getTestUser()->getUser(); + $user = $this->getMutableTestUser()->getUser(); $userIdentity = $this->getMock( UserIdentity::class ); $userIdentity->method( 'getId' )->willReturn( $user->getId() ); $userIdentity->method( 'getName' )->willReturn( $user->getName() ); @@ -673,7 +677,7 @@ class ActorMigrationTest extends MediaWikiLangTestCase { list( $cFields, $cCallback ) = MediaWikiServices::getInstance()->getCommentStore() ->insertWithTempTable( $this->db, 'rev_comment', '' ); - $m = $this->makeMigration( SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW ); + $m = $this->makeMigration( $stage ); list( $fields, $callback ) = $m->getInsertValuesWithTempTable( $this->db, 'rev_user', $userIdentity ); $extraFields = [ @@ -692,13 +696,25 @@ class ActorMigrationTest extends MediaWikiLangTestCase { ); $this->assertSame( $user->getId(), (int)$row->rev_user ); $this->assertSame( $user->getName(), $row->rev_user_text ); - $this->assertSame( $user->getActorId(), (int)$row->rev_actor ); + $this->assertSame( + ( $stage & SCHEMA_COMPAT_READ_NEW ) ? $user->getActorId() : 0, + (int)$row->rev_actor + ); - $m = $this->makeMigration( SCHEMA_COMPAT_WRITE_BOTH | SCHEMA_COMPAT_READ_NEW ); + $m = $this->makeMigration( $stage ); $fields = $m->getInsertValues( $this->db, 'dummy_user', $userIdentity ); - $this->assertSame( $user->getId(), $fields['dummy_user'] ); - $this->assertSame( $user->getName(), $fields['dummy_user_text'] ); - $this->assertSame( $user->getActorId(), $fields['dummy_actor'] ); + if ( $stage & SCHEMA_COMPAT_WRITE_OLD ) { + $this->assertSame( $user->getId(), $fields['dummy_user'] ); + $this->assertSame( $user->getName(), $fields['dummy_user_text'] ); + } else { + $this->assertArrayNotHasKey( 'dummy_user', $fields ); + $this->assertArrayNotHasKey( 'dummy_user_text', $fields ); + } + if ( $stage & SCHEMA_COMPAT_WRITE_NEW ) { + $this->assertSame( $user->getActorId(), $fields['dummy_actor'] ); + } else { + $this->assertArrayNotHasKey( 'dummy_actor', $fields ); + } } public function testNewMigration() {