a0bac639581abdef6b7b3775362b9f3b16116af1
[lhc/web/wiklou.git] / tests / phpunit / includes / externalstore / ExternalStoreFactoryTest.php
1 <?php
2
3 /**
4 * @covers ExternalStoreFactory
5 */
6 class ExternalStoreFactoryTest extends PHPUnit_Framework_TestCase {
7
8 public function testExternalStoreFactory_noStores() {
9 $factory = new ExternalStoreFactory( [] );
10 $this->assertFalse( $factory->getStoreObject( 'ForTesting' ) );
11 $this->assertFalse( $factory->getStoreObject( 'foo' ) );
12 }
13
14 public function provideStoreNames() {
15 yield 'Same case as construction' => [ 'ForTesting' ];
16 yield 'All lower case' => [ 'fortesting' ];
17 yield 'All upper case' => [ 'FORTESTING' ];
18 yield 'Mix of cases' => [ 'FOrTEsTInG' ];
19 }
20
21 /**
22 * @dataProvider provideStoreNames
23 */
24 public function testExternalStoreFactory_someStore_protoMatch( $proto ) {
25 $factory = new ExternalStoreFactory( [ 'ForTesting' ] );
26 $store = $factory->getStoreObject( $proto );
27 $this->assertInstanceOf( ExternalStoreForTesting::class, $store );
28 }
29
30 /**
31 * @dataProvider provideStoreNames
32 */
33 public function testExternalStoreFactory_someStore_noProtoMatch( $proto ) {
34 $factory = new ExternalStoreFactory( [ 'SomeOtherClassName' ] );
35 $store = $factory->getStoreObject( $proto );
36 $this->assertFalse( $store );
37 }
38
39 }