summaryrefslogtreecommitdiff
path: root/www/wiki/tests/phpunit/includes/externalstore/ExternalStoreFactoryTest.php
blob: f7626938640ecd3f544df508858ba1a455e8c22b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

/**
 * @covers ExternalStoreFactory
 */
class ExternalStoreFactoryTest extends PHPUnit\Framework\TestCase {

	use MediaWikiCoversValidator;

	public function testExternalStoreFactory_noStores() {
		$factory = new ExternalStoreFactory( [] );
		$this->assertFalse( $factory->getStoreObject( 'ForTesting' ) );
		$this->assertFalse( $factory->getStoreObject( 'foo' ) );
	}

	public function provideStoreNames() {
		yield 'Same case as construction' => [ 'ForTesting' ];
		yield 'All lower case' => [ 'fortesting' ];
		yield 'All upper case' => [ 'FORTESTING' ];
		yield 'Mix of cases' => [ 'FOrTEsTInG' ];
	}

	/**
	 * @dataProvider provideStoreNames
	 */
	public function testExternalStoreFactory_someStore_protoMatch( $proto ) {
		$factory = new ExternalStoreFactory( [ 'ForTesting' ] );
		$store = $factory->getStoreObject( $proto );
		$this->assertInstanceOf( ExternalStoreForTesting::class, $store );
	}

	/**
	 * @dataProvider provideStoreNames
	 */
	public function testExternalStoreFactory_someStore_noProtoMatch( $proto ) {
		$factory = new ExternalStoreFactory( [ 'SomeOtherClassName' ] );
		$store = $factory->getStoreObject( $proto );
		$this->assertFalse( $store );
	}

}