Esempio n. 1
0
 public function enable()
 {
     if (!empty(self::$instance)) {
         if (self::$instance == $this) {
             return;
         }
         throw new Exception("Another WikiaMockProxy is already enabled");
     }
     // enable this instance
     self::$instance = $this;
     $this->enabled = true;
     set_new_overload('WikiaMockProxy::overload');
     foreach ($this->mocks as $list1) {
         foreach ($list1 as $type => $mock) {
             $this->notify($mock[self::PROP_ACTION]);
         }
     }
 }
Esempio n. 2
0
}
function wfMsgRealStub()
{
    return '';
}
function wfGetDBStub()
{
    throw new WikiaException('No DB in unit tests');
}
function sno_callback($className)
{
    if ($className == 'Message') {
        $className = 'MessageStub';
    }
    return $className;
}
if ($wgRunningUnitTests && $wgNoDBUnits) {
    rename_function('wfMsgExt', 'wfMsgExt_orig');
    rename_function('wfMsgReal', 'wfMsgReal_orig');
    rename_function('wfGetDB', 'wfGetDB_orig');
    rename_function('wfMsgExtStub', 'wfMsgExt');
    rename_function('wfMsgRealStub', 'wfMsgReal');
    rename_function('wfGetDBStub', 'wfGetDB');
    $wgMemc = new FakeCache();
    $messageMemc = null;
    $parserMemc = null;
    set_new_overload('sno_callback');
}
require_once 'Zend/Exception.php';
require_once 'Zend/Config.php';
require_once 'Zend/Config/Exception.php';
Esempio n. 3
0
 /**
  * @todo Implement testGetUserTrashDirURI().
  */
 public function testGetUserTrashDirURI()
 {
     $this->markTestIncomplete('This test has not been implemented yet.');
     // THIS TEST NEEDS TO BE FIXED - it causes a segmentation violation on Hudson (different PHP version?)
     // No RODSConnMOck defined? Or perhaps need to use stubRODSConn instead
     // set up mock parameters
     $retval = $this->stubGetUserInfo();
     $mocked_rodsacct_methods = array('getUserInfo');
     $mocked_rodsacct_construct_params = array($this->host, $this->port, $this->name, $this->passwd, $this->zone);
     $acct_stub = $this->getMock('RODSAccount', $mocked_rodsacct_methods, $mocked_rodsacct_construct_params);
     $acct_stub->expects($this->once())->method('getUserInfo')->will($this->returnValue($retval));
     //set up overload for constructors
     set_new_overload(array($this, 'newCallback'));
     // now run actual tests
     $acct_stub->zone = null;
     $p = $acct_stub->getUserTrashDirURI();
     $expected = $acct_stub->user . "@" . $acct_stub->host . ":" . $acct_stub->port . "//trash/home/" . $acct_stub->user;
     $this->assertEquals($expected, $p);
     // noew test with zone set - getUserInfo() should never be called
     $acct_stub->zone = $this->zone;
     $acct_stub->expects($this->never())->method('getUserInfo')->will($this->returnValue($retval));
     $p = $acct_stub->getUserTrashDirURI();
     $expected = $acct_stub->user . "." . $acct_stub->zone . "@" . $acct_stub->host . ":" . $acct_stub->port . "/" . $acct_stub->zone . "/trash/home/" . $acct_stub->user;
     $this->assertEquals($expected, $p);
     unset_new_overload();
 }
Esempio n. 4
0
 /**
  * Rename a class
  *
  * If no replacement is specified, it will rename $className to
  * $className . 'Stub'.
  *
  * When you pass in an array, then the first time the object is created,
  * it will use the first name.  The second instantiation would use
  * the second class, and so forth.  When at the end, it will start again
  * from the beginning.
  *
  * @param string $originalName Original class name
  * @param string|array $replacement Replacement name or names
  */
 public function renameClass($originalName, $replacement = null)
 {
     if (!extension_loaded('test_helpers')) {
         die('test_helpers extension is required');
     }
     if (is_null($replacement)) {
         $replacement = $originalName . 'Stub';
     }
     if (count(static::$renamedClasses) === 0) {
         // Reset, just in case
         unset_new_overload();
         set_new_overload(array('Renamer', 'getClassName'));
     }
     // Class names are case insensitive
     $key = strtolower($originalName);
     static::$renamedClasses[$key] = $replacement;
 }