Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / externalstore / ExternalStoreTest.php
blobf98beefb472422d7e9680474a9184e6e7da75b9e
1 <?php
3 class ExternalStoreTest extends MediaWikiIntegrationTestCase {
5 /**
6 * @covers \ExternalStore::fetchFromURL
7 */
8 public function testExternalFetchFromURL_noExternalStores() {
9 $this->setService(
10 'ExternalStoreFactory',
11 new ExternalStoreFactory( [], [], 'test-id' )
14 $this->assertFalse(
15 ExternalStore::fetchFromURL( 'ForTesting://cluster1/200' ),
16 'Deny if wgExternalStores is not set to a non-empty array'
20 public static function provideFetchFromURLWithStore() {
21 yield [ 'Hello', 'ForTesting://cluster1/200', 'Allow ForTesting://cluster1/200' ];
22 yield [ 'Hello', 'ForTesting://cluster1/300/0', 'Allow ForTesting://cluster1/300/0' ];
24 // cases for r68900
25 yield [ false, 'ftp.example.org', 'Deny domain ftp.example.org' ];
26 yield [ false, '/example.txt', 'Deny path /example.txt' ];
27 yield [ false, 'http://', 'Deny protocol http://' ];
30 /**
31 * @covers \ExternalStore::fetchFromURL
32 * @dataProvider provideFetchFromURLWithStore
34 public function testExternalFetchFromURL_someExternalStore( $expect, $url, $msg ) {
35 $this->setService(
36 'ExternalStoreFactory',
37 new ExternalStoreFactory( [ 'ForTesting' ], [ 'ForTesting://cluster1' ], 'test-id' )
40 $this->assertSame( $expect, ExternalStore::fetchFromURL( $url ), $msg );