Merge "Treat phpdbg as run from the command line when checking PHP_SAPI"
[lhc/web/wiklou.git] / tests / phpunit / includes / Storage / BlobStoreFactoryTest.php
1 <?php
2
3 namespace MediaWiki\Tests\Storage;
4
5 use MediaWiki\MediaWikiServices;
6 use MediaWiki\Storage\BlobStore;
7 use MediaWiki\Storage\SqlBlobStore;
8 use MediaWikiTestCase;
9 use Wikimedia\TestingAccessWrapper;
10
11 /**
12 * @covers \MediaWiki\Storage\BlobStoreFactory
13 */
14 class BlobStoreFactoryTest extends MediaWikiTestCase {
15
16 public function provideWikiIds() {
17 yield [ false ];
18 yield [ 'someWiki' ];
19 }
20
21 /**
22 * @dataProvider provideWikiIds
23 */
24 public function testNewBlobStore( $wikiId ) {
25 $factory = MediaWikiServices::getInstance()->getBlobStoreFactory();
26 $store = $factory->newBlobStore( $wikiId );
27 $this->assertInstanceOf( BlobStore::class, $store );
28
29 // This only works as we currently know this is a SqlBlobStore object
30 $wrapper = TestingAccessWrapper::newFromObject( $store );
31 $this->assertEquals( $wikiId, $wrapper->wikiId );
32 }
33
34 /**
35 * @dataProvider provideWikiIds
36 */
37 public function testNewSqlBlobStore( $wikiId ) {
38 $factory = MediaWikiServices::getInstance()->getBlobStoreFactory();
39 $store = $factory->newSqlBlobStore( $wikiId );
40 $this->assertInstanceOf( SqlBlobStore::class, $store );
41
42 $wrapper = TestingAccessWrapper::newFromObject( $store );
43 $this->assertEquals( $wikiId, $wrapper->wikiId );
44 }
45
46 }