<?php
+use MediaWiki\Storage\BlobStoreFactory;
use MediaWiki\Storage\RevisionStore;
use MediaWiki\Storage\SqlBlobStore;
use Wikimedia\Rdbms\IDatabase;
->method( 'getPrefixedText' )
->will( $this->returnValue( 'RevisionTest' ) );
$mock->expects( $this->any() )
- ->method( 'getDBKey' )
+ ->method( 'getDBkey' )
->will( $this->returnValue( 'RevisionTest' ) );
$mock->expects( $this->any() )
->method( 'getArticleID' )
/**
* @dataProvider provideConstructFromArrayThrowsExceptions
* @covers Revision::__construct
- * @covers RevisionStore::newMutableRevisionFromArray
+ * @covers \MediaWiki\Storage\RevisionStore::newMutableRevisionFromArray
*/
public function testConstructFromArrayThrowsExceptions( $rowArray, Exception $expectedException ) {
$this->setExpectedException(
/**
* @covers Revision::__construct
- * @covers RevisionStore::newMutableRevisionFromArray
+ * @covers \MediaWiki\Storage\RevisionStore::newMutableRevisionFromArray
*/
public function testConstructFromNothing() {
$this->setExpectedException(
/**
* @dataProvider provideConstructFromRow
* @covers Revision::__construct
- * @covers RevisionStore::newRevisionFromRow
+ * @covers \MediaWiki\Storage\RevisionStore::newMutableRevisionFromArray
*/
public function testConstructFromRow( array $arrayData, $assertions ) {
$data = 'Hello goat.'; // needs to match model and format
) );
// Note override internal service, so RevisionStore uses it as well.
- $this->setService( '_SqlBlobStore', $blobStore );
+ $this->setService( 'BlobStoreFactory', $this->mockBlobStoreFactory( $blobStore ) );
$row = (object)$arrayData;
$rev = new Revision( $row, 0, $this->getMockTitle() );
return $blobStore;
}
+ private function mockBlobStoreFactory( $blobStore ) {
+ /** @var LoadBalancer $lb */
+ $factory = $this->getMockBuilder( BlobStoreFactory::class )
+ ->disableOriginalConstructor()
+ ->getMock();
+ $factory->expects( $this->any() )
+ ->method( 'newBlobStore' )
+ ->willReturn( $blobStore );
+ $factory->expects( $this->any() )
+ ->method( 'newSqlBlobStore' )
+ ->willReturn( $blobStore );
+ return $factory;
+ }
+
/**
* @return RevisionStore
*/
public function testGetRevisionWithLegacyEncoding( $expected, $lang, $encoding, $rowData ) {
$blobStore = $this->getBlobStore();
$blobStore->setLegacyEncoding( $encoding, Language::factory( $lang ) );
- $this->setService( 'BlobStore', $blobStore );
+ $this->setService( 'BlobStoreFactory', $this->mockBlobStoreFactory( $blobStore ) );
$this->testGetRevisionText( $expected, $rowData );
}
$blobStore = $this->getBlobStore();
$blobStore->setLegacyEncoding( $encoding, Language::factory( $lang ) );
- $this->setService( 'BlobStore', $blobStore );
+ $this->setService( 'BlobStoreFactory', $this->mockBlobStoreFactory( $blobStore ) );
$this->testGetRevisionText( $expected, $rowData );
}
$blobStore = $this->getBlobStore();
$blobStore->setCompressBlobs( true );
- $this->setService( 'BlobStore', $blobStore );
+ $this->setService( 'BlobStoreFactory', $this->mockBlobStoreFactory( $blobStore ) );
$row = new stdClass;
$row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
$blobStore->setLegacyEncoding( $legacyEncoding, Language::factory( 'en' ) );
}
- $this->setService( 'BlobStore', $blobStore );
+ $this->setService( 'BlobStoreFactory', $this->mockBlobStoreFactory( $blobStore ) );
$this->assertSame(
$expected,
Revision::decompressRevisionText( $text, $flags )
->getMock();
$blobStore = new SqlBlobStore( $lb, $cache );
- $this->setService( 'BlobStore', $blobStore );
+ $this->setService( 'BlobStoreFactory', $this->mockBlobStoreFactory( $blobStore ) );
$this->assertSame(
'AAAABBAAA',