6 class ExternalStoreTest
extends MediaWikiTestCase
{
9 * @covers ExternalStore::fetchFromURL
11 public function testExternalFetchFromURL() {
12 $this->setMwGlobals( 'wgExternalStores', false );
15 ExternalStore
::fetchFromURL( 'FOO://cluster1/200' ),
16 'Deny if wgExternalStores is not set to a non-empty array'
19 $this->setMwGlobals( 'wgExternalStores', array( 'FOO' ) );
22 ExternalStore
::fetchFromURL( 'FOO://cluster1/200' ),
24 'Allow FOO://cluster1/200'
27 ExternalStore
::fetchFromURL( 'FOO://cluster1/300/0' ),
29 'Allow FOO://cluster1/300/0'
31 # Assertions for r68900
33 ExternalStore
::fetchFromURL( 'ftp.example.org' ),
34 'Deny domain ftp.example.org'
37 ExternalStore
::fetchFromURL( '/example.txt' ),
38 'Deny path /example.txt'
41 ExternalStore
::fetchFromURL( 'http://' ),
42 'Deny protocol http://'
47 class ExternalStoreFOO
{
49 protected $data = array(
59 * Fetch data from given URL
60 * @param string $url An url of the form FOO://cluster/id or FOO://cluster/id/itemid.
63 function fetchFromURL( $url ) {
64 // Based on ExternalStoreDB
65 $path = explode( '/', $url );
68 if ( isset( $path[4] ) ) {
74 if ( !isset( $this->data
[$cluster][$id] ) ) {
78 if ( $itemID !== false
79 && is_array( $this->data
[$cluster][$id] )
80 && isset( $this->data
[$cluster][$id][$itemID] )
82 return $this->data
[$cluster][$id][$itemID];
85 return $this->data
[$cluster][$id];