6 class ExternalStoreTest
extends MediaWikiTestCase
{
8 function testExternalFetchFromURL() {
9 $this->setMwGlobals( 'wgExternalStores', false );
12 ExternalStore
::fetchFromURL( 'FOO://cluster1/200' ),
13 'Deny if wgExternalStores is not set to a non-empty array'
16 $this->setMwGlobals( 'wgExternalStores', array( 'FOO' ) );
19 ExternalStore
::fetchFromURL( 'FOO://cluster1/200' ),
21 'Allow FOO://cluster1/200'
24 ExternalStore
::fetchFromURL( 'FOO://cluster1/300/0' ),
26 'Allow FOO://cluster1/300/0'
28 # Assertions for r68900
30 ExternalStore
::fetchFromURL( 'ftp.example.org' ),
31 'Deny domain ftp.example.org'
34 ExternalStore
::fetchFromURL( '/example.txt' ),
35 'Deny path /example.txt'
38 ExternalStore
::fetchFromURL( 'http://' ),
39 'Deny protocol http://'
44 class ExternalStoreFOO
{
46 protected $data = array(
56 * Fetch data from given URL
57 * @param $url String: an url of the form FOO://cluster/id or FOO://cluster/id/itemid.
60 function fetchFromURL( $url ) {
61 // Based on ExternalStoreDB
62 $path = explode( '/', $url );
65 if ( isset( $path[4] ) ) {
71 if ( !isset( $this->data
[$cluster][$id] ) ) {
75 if ( $itemID !== false && is_array( $this->data
[$cluster][$id] ) && isset( $this->data
[$cluster][$id][$itemID] ) ) {
76 return $this->data
[$cluster][$id][$itemID];
79 return $this->data
[$cluster][$id];