diff options
Diffstat (limited to 'UserMerge/tests/phpunit/MergeUserTest.php')
-rw-r--r-- | UserMerge/tests/phpunit/MergeUserTest.php | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/UserMerge/tests/phpunit/MergeUserTest.php b/UserMerge/tests/phpunit/MergeUserTest.php index 06d8a287..fd60d335 100644 --- a/UserMerge/tests/phpunit/MergeUserTest.php +++ b/UserMerge/tests/phpunit/MergeUserTest.php @@ -1,7 +1,8 @@ <?php /** - * @todo this should use the Database group + * @todo this should better use the Database group + * @group Database */ class MergeUserTest extends MediaWikiTestCase { @@ -20,6 +21,15 @@ class MergeUserTest extends MediaWikiTestCase { return $user; } + public function setUp() : void { + parent::setUp(); + + $this->tablesUsed[] = 'page'; + $this->tablesUsed[] = 'revision'; + $this->tablesUsed[] = 'comment'; + $this->tablesUsed[] = 'user'; + } + /** * Clear all instance caches * @@ -40,12 +50,12 @@ class MergeUserTest extends MediaWikiTestCase { $user2 = $this->getNewTestUser(); $user2->addToDatabase(); - $mu = new MergeUser( $user1, $user2, $this->getMock( 'UserMergeLogger' ) ); - $mu->merge( $this->getMock( 'User' ) ); + $mu = new MergeUser( $user1, $user2, $this->createMock( UserMergeLogger::class ) ); + $mu->merge( $this->createMock( User::class ) ); $this->reallyClearInstanceCache( $user1 ); $this->reallyClearInstanceCache( $user2 ); - $this->assertEquals( null, $user1->getOption( 'foo' ) ); + $this->assertNull( $user1->getOption( 'foo' ) ); $this->assertEquals( 'baz', $user2->getOption( 'foo' ) ); } @@ -59,8 +69,8 @@ class MergeUserTest extends MediaWikiTestCase { $user2 = $this->getNewTestUser(); $user2->addGroup( 'group2' ); - $mu = new MergeUser( $user1, $user2, $this->getMock( 'UserMergeLogger' ) ); - $mu->merge( $this->getMock( 'User' ) ); + $mu = new MergeUser( $user1, $user2, $this->createMock( UserMergeLogger::class ) ); + $mu->merge( $this->createMock( User::class ) ); $this->reallyClearInstanceCache( $user1 ); $this->reallyClearInstanceCache( $user2 ); @@ -79,11 +89,11 @@ class MergeUserTest extends MediaWikiTestCase { $this->reallyClearInstanceCache( $user1 ); $this->assertGreaterThan( 0, $user1->getId() ); - $mu = new MergeUser( $user1, $user2, $this->getMock( 'UserMergeLogger' ) ); - $mu->delete( $this->getMock( 'User' ), 'wfMessage' ); + $mu = new MergeUser( $user1, $user2, $this->createMock( UserMergeLogger::class ) ); + $mu->delete( $this->createMock( User::class ), 'wfMessage' ); $this->reallyClearInstanceCache( $user1 ); - $this->assertEquals( 0, $user1->getId() ); + $this->assertSame( 0, $user1->getId() ); } /** @@ -100,12 +110,33 @@ class MergeUserTest extends MediaWikiTestCase { $count++; } - $mu = new MergeUser( $user1, $user2, $this->getMock( 'UserMergeLogger' ) ); - $mu->merge( $this->getMock( 'User' ) ); + $mu = new MergeUser( $user1, $user2, $this->createMock( UserMergeLogger::class ) ); + $mu->merge( $this->createMock( User::class ) ); $this->reallyClearInstanceCache( $user1 ); $this->reallyClearInstanceCache( $user2 ); - $this->assertEquals( 0, $user1->getEditCount() ); + $this->assertSame( 0, $user1->getEditCount() ); $this->assertEquals( 21, $user2->getEditCount() ); } + + /** + * @covers MergeUser::movePages + */ + public function testMovePages() { + $user1 = $this->getNewTestUser(); + $user1->addToDatabase(); + $user2 = $this->getNewTestUser(); + $user2->addToDatabase(); + + $userpage1 = $user1->getUserPage(); + $this->getExistingTestPage( $userpage1 ); + + $userpage2 = $user2->getUserPage(); + $this->assertFalse( $userpage2->exists( Title::READ_LATEST ) ); + + $mu = new MergeUser( $user1, $user2, $this->createMock( UserMergeLogger::class ) ); + $mu->delete( $this->getTestSysop()->getUser(), 'wfMessage' ); + + $this->assertTrue( $userpage2->exists( Title::READ_LATEST ) ); + } } |