MediaWiki  1.23.0
ExternalStoreTest.php
Go to the documentation of this file.
1 <?php
7 
11  public function testExternalFetchFromURL() {
12  $this->setMwGlobals( 'wgExternalStores', false );
13 
14  $this->assertFalse(
15  ExternalStore::fetchFromURL( 'FOO://cluster1/200' ),
16  'Deny if wgExternalStores is not set to a non-empty array'
17  );
18 
19  $this->setMwGlobals( 'wgExternalStores', array( 'FOO' ) );
20 
21  $this->assertEquals(
22  ExternalStore::fetchFromURL( 'FOO://cluster1/200' ),
23  'Hello',
24  'Allow FOO://cluster1/200'
25  );
26  $this->assertEquals(
27  ExternalStore::fetchFromURL( 'FOO://cluster1/300/0' ),
28  'Hello',
29  'Allow FOO://cluster1/300/0'
30  );
31  # Assertions for r68900
32  $this->assertFalse(
33  ExternalStore::fetchFromURL( 'ftp.example.org' ),
34  'Deny domain ftp.example.org'
35  );
36  $this->assertFalse(
37  ExternalStore::fetchFromURL( '/example.txt' ),
38  'Deny path /example.txt'
39  );
40  $this->assertFalse(
41  ExternalStore::fetchFromURL( 'http://' ),
42  'Deny protocol http://'
43  );
44  }
45 }
46 
48 
49  protected $data = array(
50  'cluster1' => array(
51  '200' => 'Hello',
52  '300' => array(
53  'Hello', 'World',
54  ),
55  ),
56  );
57 
63  function fetchFromURL( $url ) {
64  // Based on ExternalStoreDB
65  $path = explode( '/', $url );
66  $cluster = $path[2];
67  $id = $path[3];
68  if ( isset( $path[4] ) ) {
69  $itemID = $path[4];
70  } else {
71  $itemID = false;
72  }
73 
74  if ( !isset( $this->data[$cluster][$id] ) ) {
75  return null;
76  }
77 
78  if ( $itemID !== false && is_array( $this->data[$cluster][$id] ) && isset( $this->data[$cluster][$id][$itemID] ) ) {
79  return $this->data[$cluster][$id][$itemID];
80  }
81 
82  return $this->data[$cluster][$id];
83  }
84 }
data
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of data
Definition: hooks.txt:6
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ExternalStoreTest\testExternalFetchFromURL
testExternalFetchFromURL()
@covers ExternalStore::fetchFromURL
Definition: ExternalStoreTest.php:11
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:302
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
ExternalStoreFOO
Definition: ExternalStoreTest.php:47
ExternalStoreTest
External Store tests.
Definition: ExternalStoreTest.php:6
ExternalStore\fetchFromURL
static fetchFromURL( $url, array $params=array())
Fetch data from given URL.
Definition: ExternalStore.php:75
ExternalStoreFOO\$data
$data
Definition: ExternalStoreTest.php:49
$path
$path
Definition: NoLocalSettings.php:35
ExternalStoreFOO\fetchFromURL
fetchFromURL( $url)
Fetch data from given URL.
Definition: ExternalStoreTest.php:63