Merge "maintenance: Script to rename titles for Unicode uppercasing changes"
[lhc/web/wiklou.git] / tests / phpunit / includes / externalstore / ExternalStoreTest.php
1 <?php
2
3 class ExternalStoreTest extends MediaWikiTestCase {
4
5 /**
6 * @covers ExternalStore::fetchFromURL
7 */
8 public function testExternalFetchFromURL_noExternalStores() {
9 $this->setService(
10 'ExternalStoreFactory',
11 new ExternalStoreFactory( [], [], 'test-id' )
12 );
13
14 $this->assertFalse(
15 ExternalStore::fetchFromURL( 'ForTesting://cluster1/200' ),
16 'Deny if wgExternalStores is not set to a non-empty array'
17 );
18 }
19
20 /**
21 * @covers ExternalStore::fetchFromURL
22 */
23 public function testExternalFetchFromURL_someExternalStore() {
24 $this->setService(
25 'ExternalStoreFactory',
26 new ExternalStoreFactory( [ 'ForTesting' ], [ 'ForTesting://cluster1' ], 'test-id' )
27 );
28
29 $this->assertEquals(
30 'Hello',
31 ExternalStore::fetchFromURL( 'ForTesting://cluster1/200' ),
32 'Allow FOO://cluster1/200'
33 );
34 $this->assertEquals(
35 'Hello',
36 ExternalStore::fetchFromURL( 'ForTesting://cluster1/300/0' ),
37 'Allow FOO://cluster1/300/0'
38 );
39 # Assertions for r68900
40 $this->assertFalse(
41 ExternalStore::fetchFromURL( 'ftp.example.org' ),
42 'Deny domain ftp.example.org'
43 );
44 $this->assertFalse(
45 ExternalStore::fetchFromURL( '/example.txt' ),
46 'Deny path /example.txt'
47 );
48 $this->assertFalse(
49 ExternalStore::fetchFromURL( 'http://' ),
50 'Deny protocol http://'
51 );
52 }
53 }