'actor',
];
- /**
- * Create an ActorMigration for a particular stage
- * @param int $stage
- * @return ActorMigration
- */
- protected function makeMigration( $stage ) {
- return new ActorMigration( $stage );
- }
-
/**
* @dataProvider provideConstructor
* @param int $stage
* @param array $expect
*/
public function testGetJoin( $stage, $key, $expect ) {
- $m = $this->makeMigration( $stage );
+ $m = new ActorMigration( $stage );
$result = $m->getJoin( $key );
$this->assertEquals( $expect, $result );
}
$users = reset( $users );
}
- $m = $this->makeMigration( $stage );
+ $m = new ActorMigration( $stage );
$result = $m->getWhere( $this->db, $key, $users, $useId );
$this->assertEquals( $expect, $result );
}
$extraFields['ipb_address'] = __CLASS__ . "#{$stageNames[$writeStage]}";
}
- $w = $this->makeMigration( $writeStage );
+ $w = new ActorMigration( $writeStage );
$usesTemp = $key === 'rev_user';
if ( $usesTemp ) {
}
foreach ( $possibleReadStages as $readStage ) {
- $r = $this->makeMigration( $readStage );
+ $r = new ActorMigration( $readStage );
$queryInfo = $r->getJoin( $key );
$row = $this->db->selectRow(
* @expectedExceptionMessage Must use getInsertValuesWithTempTable() for rev_user
*/
public function testInsertWrong( $stage ) {
- $m = $this->makeMigration( $stage );
+ $m = new ActorMigration( $stage );
$m->getInsertValues( $this->db, 'rev_user', $this->getTestUser()->getUser() );
}
* @expectedExceptionMessage Must use getInsertValues() for rc_user
*/
public function testInsertWithTempTableWrong( $stage ) {
- $m = $this->makeMigration( $stage );
+ $m = new ActorMigration( $stage );
$m->getInsertValuesWithTempTable( $this->db, 'rc_user', $this->getTestUser()->getUser() );
}
$wrap->formerTempTables += [ 'rc_user' => '1.30' ];
$this->hideDeprecated( 'ActorMigration::getInsertValuesWithTempTable for rc_user' );
- $m = $this->makeMigration( $stage );
+ $m = new ActorMigration( $stage );
list( $fields, $callback )
= $m->getInsertValuesWithTempTable( $this->db, 'rc_user', $this->getTestUser()->getUser() );
$this->assertTrue( is_callable( $callback ) );
* @expectedExceptionMessage $extra[rev_timestamp] is not provided
*/
public function testInsertWithTempTableCallbackMissingFields( $stage ) {
- $m = $this->makeMigration( $stage );
+ $m = new ActorMigration( $stage );
list( $fields, $callback )
= $m->getInsertValuesWithTempTable( $this->db, 'rev_user', $this->getTestUser()->getUser() );
$callback( 1, [] );
list( $cFields, $cCallback ) = MediaWikiServices::getInstance()->getCommentStore()
->insertWithTempTable( $this->db, 'rev_comment', '' );
- $m = $this->makeMigration( $stage );
+ $m = new ActorMigration( $stage );
list( $fields, $callback ) =
$m->getInsertValuesWithTempTable( $this->db, 'rev_user', $userIdentity );
$extraFields = [
(int)$row->rev_actor
);
- $m = $this->makeMigration( $stage );
+ $m = new ActorMigration( $stage );
$fields = $m->getInsertValues( $this->db, 'dummy_user', $userIdentity );
if ( $stage & SCHEMA_COMPAT_WRITE_OLD ) {
$this->assertSame( $user->getId(), $fields['dummy_user'] );
* @param string $isNotAnon
*/
public function testIsAnon( $stage, $isAnon, $isNotAnon ) {
- $m = $this->makeMigration( $stage );
+ $m = new ActorMigration( $stage );
$this->assertSame( $isAnon, $m->isAnon( 'foo' ) );
$this->assertSame( $isNotAnon, $m->isNotAnon( 'foo' ) );
}
return $row;
}
- private function getTitleArrayFromResult( $resultWrapper ) {
- return new TitleArrayFromResult( $resultWrapper );
- }
-
/**
* @covers TitleArrayFromResult::__construct
*/
$row = false;
$resultWrapper = $this->getMockResultWrapper( $row );
- $object = $this->getTitleArrayFromResult( $resultWrapper );
+ $object = new TitleArrayFromResult( $resultWrapper );
$this->assertEquals( $resultWrapper, $object->res );
$this->assertSame( 0, $object->key );
$row = $this->getRowWithTitle( $namespace, $title );
$resultWrapper = $this->getMockResultWrapper( $row );
- $object = $this->getTitleArrayFromResult( $resultWrapper );
+ $object = new TitleArrayFromResult( $resultWrapper );
$this->assertEquals( $resultWrapper, $object->res );
$this->assertSame( 0, $object->key );
* @covers TitleArrayFromResult::count
*/
public function testCountWithVaryingValues( $numRows ) {
- $object = $this->getTitleArrayFromResult( $this->getMockResultWrapper(
+ $object = new TitleArrayFromResult( $this->getMockResultWrapper(
$this->getRowWithTitle(),
$numRows
) );
$namespace = 0;
$title = 'foo';
$row = $this->getRowWithTitle( $namespace, $title );
- $object = $this->getTitleArrayFromResult( $this->getMockResultWrapper( $row ) );
+ $object = new TitleArrayFromResult( $this->getMockResultWrapper( $row ) );
$this->assertInstanceOf( Title::class, $object->current() );
$this->assertEquals( $namespace, $object->current->mNamespace );
$this->assertEquals( $title, $object->current->mTextform );
* @covers TitleArrayFromResult::valid
*/
public function testValid( $input, $expected ) {
- $object = $this->getTitleArrayFromResult( $this->getMockResultWrapper( $input ) );
+ $object = new TitleArrayFromResult( $this->getMockResultWrapper( $input ) );
$this->assertEquals( $expected, $object->valid() );
}
*/
class ImportTest extends MediaWikiLangTestCase {
- private function getDataSource( $xml ) {
- return new ImportStringSource( $xml );
- }
-
/**
* @covers WikiImporter
* @dataProvider getUnknownTagsXML
* @param string $title
*/
public function testUnknownXMLTags( $xml, $text, $title ) {
- $source = $this->getDataSource( $xml );
+ $source = new ImportStringSource( $xml );
$importer = new WikiImporter(
$source,
* @param string|null $redirectTitle
*/
public function testHandlePageContainsRedirect( $xml, $redirectTitle ) {
- $source = $this->getDataSource( $xml );
+ $source = new ImportStringSource( $xml );
$redirect = null;
$callback = function ( Title $title, ForeignTitle $foreignTitle, $revCount,
* @param array|null $namespaces
*/
public function testSiteInfoContainsNamespaces( $xml, $namespaces ) {
- $source = $this->getDataSource( $xml );
+ $source = new ImportStringSource( $xml );
$importNamespaces = null;
$callback = function ( array $siteinfo, $innerImporter ) use ( &$importNamespaces ) {
$n = ( $assign ? 1 : 0 ) + ( $create ? 2 : 0 );
// phpcs:disable Generic.Files.LineLength
- $source = $this->getDataSource( <<<EOF
+ $source = new ImportStringSource( <<<EOF
<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.10/ http://www.mediawiki.org/xml/export-0.10.xsd" version="0.10" xml:lang="en">
<page>
<title>TestImportPage</title>
return $row;
}
- private function getUserArrayFromResult( $resultWrapper ) {
- return new UserArrayFromResult( $resultWrapper );
- }
-
/**
* @covers UserArrayFromResult::__construct
*/
$row = false;
$resultWrapper = $this->getMockResultWrapper( $row );
- $object = $this->getUserArrayFromResult( $resultWrapper );
+ $object = new UserArrayFromResult( $resultWrapper );
$this->assertEquals( $resultWrapper, $object->res );
$this->assertSame( 0, $object->key );
$row = $this->getRowWithUsername( $username );
$resultWrapper = $this->getMockResultWrapper( $row );
- $object = $this->getUserArrayFromResult( $resultWrapper );
+ $object = new UserArrayFromResult( $resultWrapper );
$this->assertEquals( $resultWrapper, $object->res );
$this->assertSame( 0, $object->key );
* @covers UserArrayFromResult::count
*/
public function testCountWithVaryingValues( $numRows ) {
- $object = $this->getUserArrayFromResult( $this->getMockResultWrapper(
+ $object = new UserArrayFromResult( $this->getMockResultWrapper(
$this->getRowWithUsername(),
$numRows
) );
public function testCurrentAfterConstruction() {
$username = 'addshore';
$userRow = $this->getRowWithUsername( $username );
- $object = $this->getUserArrayFromResult( $this->getMockResultWrapper( $userRow ) );
+ $object = new UserArrayFromResult( $this->getMockResultWrapper( $userRow ) );
$this->assertInstanceOf( User::class, $object->current() );
$this->assertEquals( $username, $object->current()->mName );
}
* @covers UserArrayFromResult::valid
*/
public function testValid( $input, $expected ) {
- $object = $this->getUserArrayFromResult( $this->getMockResultWrapper( $input ) );
+ $object = new UserArrayFromResult( $this->getMockResultWrapper( $input ) );
$this->assertEquals( $expected, $object->valid() );
}