var $oldFileFactory = false;
var $fileFactoryKey = false, $oldFileFactoryKey = false;
- function __construct( $info ) {
+ function __construct( Array $info = null ) {
+ // Verify required settings presence
+ if(
+ $info === null
+ || !array_key_exists( 'name', $info )
+ || !array_key_exists( 'backend', $info )
+ ) {
+ throw new MWException( __CLASS__ . " requires an array of options having both 'name' and 'backend' keys.\n" );
+ }
+
// Required settings
$this->name = $info['name'];
if ( $info['backend'] instanceof FileBackendBase ) {
--- /dev/null
+<?php
+
+class FileRepoTest extends MediaWikiTestCase {
+
+ /**
+ * @expectedException MWException
+ */
+ function testFileRepoConstructionOptionCanNotBeNull() {
+ $f = new FileRepo();
+ }
+ /**
+ * @expectedException MWException
+ */
+ function testFileRepoConstructionOptionCanNotBeAnEmptyArray() {
+ $f = new FileRepo( array() );
+ }
+ /**
+ * @expectedException MWException
+ */
+ function testFileRepoConstructionOptionNeedNameKey() {
+ $f = new FileRepo( array(
+ 'backend' => 'foobar'
+ ) );
+ }
+ /**
+ * @expectedException MWException
+ */
+ function testFileRepoConstructionOptionNeedBackendKey() {
+ $f = new FileRepo( array(
+ 'name' => 'foobar'
+ ) );
+ }
+
+}