当前位置: 首页>>代码示例>>PHP>>正文


PHP F::setInstance方法代码示例

本文整理汇总了PHP中F::setInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP F::setInstance方法的具体用法?PHP F::setInstance怎么用?PHP F::setInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在F的用法示例。


在下文中一共展示了F::setInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 function __construct()
 {
     $this->app = F::app();
     $this->logger = F::build('PathFinderLogger');
     //singleton
     F::setInstance(__CLASS__, $this);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:7,代码来源:PathFinderModel.class.php

示例2: setUp

 protected function setUp()
 {
     global $wgCityId;
     $this->wgCityId = $wgCityId;
     $this->setupFile = dirname(__FILE__) . '/../FounderProgressBar.setup.php';
     parent::setUp();
     // Mock response using $this->getValCallBack()
     $mockR = $this->getMock('WikiaResponse', array('getVal'), array('raw'));
     $mockR->expects($this->any())->method('getVal')->will($this->returnCallback(array($this, "getValCallback")));
     $mock_result = $this->getMock('ResultWrapper', array(), array(), '', false);
     $this->mock_db = $this->getMock('DatabaseMysql', array('select', 'query', 'update', 'commit', 'fetchObject', 'fetchRow'));
     $this->mock_db->expects($this->any())->method('select')->will($this->returnValue($mock_result));
     $this->mock_db->expects($this->any())->method('query');
     $this->mock_db->expects($this->any())->method('update');
     $this->mock_db->expects($this->any())->method('commit');
     $cache = $this->getMock('stdClass', array('get', 'set', 'delete'));
     $cache->expects($this->any())->method('get')->will($this->returnValue(null));
     $cache->expects($this->any())->method('set');
     $cache->expects($this->any())->method('delete');
     $mock = $this->getMock('FounderProgressBarController', array('sendSelfRequest', 'getDb', 'getMCache'));
     $mock->expects($this->any())->method('sendSelfRequest')->will($this->returnValue($mockR));
     $mock->expects($this->any())->method('getDb')->will($this->returnValue($this->mock_db));
     $mock->expects($this->any())->method('getMCache')->will($this->returnValue($cache));
     F::setInstance("FounderProgressBarController", $mock);
     $this->object = F::build('FounderProgressBarController');
     $this->task_id = 0;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:27,代码来源:FounderProgressBarTest.php

示例3: __construct

 /**
  * constructor
  * @param $globalRegistry WikiaGlobalRegistry
  * @param $localRegistry WikiaLocalRegistry
  * @param $hookDispatcher WikiaHookDispatcher
  */
 public function __construct(WikiaGlobalRegistry $globalRegistry = null, WikiaLocalRegistry $localRegistry = null, WikiaHookDispatcher $hookDispatcher = null, WikiaFunctionWrapper $functionWrapper = null)
 {
     if (!is_object($globalRegistry)) {
         F::setInstance('WikiaGlobalRegistry', new WikiaGlobalRegistry());
         $globalRegistry = F::build('WikiaGlobalRegistry');
     }
     if (!is_object($localRegistry)) {
         F::setInstance('WikiaLocalRegistry', new WikiaLocalRegistry());
         $localRegistry = F::build('WikiaLocalRegistry');
     }
     if (!is_object($hookDispatcher)) {
         F::setInstance('WikiaHookDispatcher', new WikiaHookDispatcher());
         $hookDispatcher = F::build('WikiaHookDispatcher');
     }
     if (!is_object($functionWrapper)) {
         $functionWrapper = F::build('WikiaFunctionWrapper');
     }
     $this->localRegistry = $localRegistry;
     $this->hookDispatcher = $hookDispatcher;
     // set helper accessors
     $this->wg = $globalRegistry;
     $this->wf = $functionWrapper;
     // register ajax dispatcher
     if (is_object($this->wg)) {
         $this->wg->append('wgAjaxExportList', 'WikiaApp::ajax');
     } else {
         Wikia::log(__METHOD__, false, 'WikiaGlobalRegistry not set in ' . __CLASS__ . ' ' . __METHOD__);
         Wikia::logBacktrace(__METHOD__);
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:36,代码来源:WikiaApp.class.php

示例4: setStubsForImageReviewSpecialControllerTests

 private function setStubsForImageReviewSpecialControllerTests($error)
 {
     //our test have all needed rights ;)
     $specialPageStub = $this->getMock('SpecialPage', array('userCanExecute'));
     $specialPageStub->expects($this->any())->method('userCanExecute')->will($this->returnValue(true));
     F::setInstance('SpecialPage', $specialPageStub);
     //to prevent fatal error
     $wgTitleStub = $this->getMock('Title', array('getFullUrl'));
     $wgTitleStub->expects($this->any())->method('getFullUrl')->will($this->returnValue($this->fakeUrl));
     $this->mockGlobalVariable('wgTitle', $wgTitleStub);
     //not to stop ImageSpecialController() 'cause ts parameter not given
     $wgRequestStub = $this->getMock('Request', array('getVal', 'wasPosted'));
     $wgRequestStub->expects($this->any())->method('getVal')->will($this->returnValue($this->fakeTimestamp));
     $wgRequestStub->expects($this->any())->method('wasPosted')->will($this->returnValue(false));
     $this->mockGlobalVariable('wgRequest', $wgRequestStub);
     if (!$error) {
         $memcTs = $this->fakeUserTs + 1;
         $imageReviewHelperStub = $this->getMock('ImageReviewHelper', array('refetchImageListByTimestamp'));
         $imageReviewHelperStub->expects($this->once())->method('refetchImageListByTimestamp')->will($this->returnValue($this->fakeCorrectImages));
     } else {
         $memcTs = $this->fakeUserTs - 1;
         $imageReviewHelperStub = $this->getMock('ImageReviewHelper', array('getImageList'));
         $imageReviewHelperStub->expects($this->once())->method('getImageList')->will($this->returnValue($this->fakeWrongImages));
     }
     F::setInstance('ImageReviewHelper', $imageReviewHelperStub);
     $wgMemcStub = $this->getMock('wgMemc', array('get', 'set'));
     $wgMemcStub->expects($this->any())->method('get')->will($this->returnValue($memcTs));
     $this->mockGlobalVariable('wgMemc', $wgMemcStub);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:29,代码来源:ImageReviewTest.php

示例5: __construct

 function __construct()
 {
     $this->app = F::app();
     $this->magicWords = array_keys($this->app->wg->LandingPagesAsContentMagicWords);
     //singleton
     F::setInstance(__CLASS__, $this);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:7,代码来源:LandingPagesParser.class.php

示例6: testCreateWikiSuccess

 /**
  * @group hyun
  */
 public function testCreateWikiSuccess()
 {
     $wikiName = 'Muppet is great';
     $wikiDomain = 'muppet';
     $wikiLanguage = 'en';
     $wikiCategory = '3';
     $wikiId = 322389;
     $wikiAnswer = 12345;
     $siteName = 'asdfasdf';
     $mainPageUrl = 'muppet.wikia.com/wiki/Main_page';
     $requestParams = array("wName" => $wikiName, "wDomain" => $wikiDomain, "wLanguage" => $wikiLanguage, "wCategory" => $wikiCategory, "wAnswer" => $wikiAnswer);
     $wgRequest = $this->getMock('WebRequest');
     $wgRequest->expects($this->once())->method('getArray')->will($this->returnValue($requestParams));
     $wgDevelDomains = array();
     $wgUser = $this->getMock('User');
     $wgUser->expects($this->once())->method('getId')->will($this->returnValue(6));
     $app = $this->getMock('WikiaApp', array('getGlobal', 'runFunction'));
     $app->expects($this->exactly(3))->method('getGlobal')->will($this->onConsecutiveCalls($wgRequest, $wgDevelDomains, $wgUser));
     $createWiki = $this->getMock('CreateWiki', array('create', 'getWikiInfo'), array(), '', false);
     $createWiki->expects($this->once())->method('create');
     $createWiki->expects($this->exactly(2))->method('getWikiInfo')->will($this->onConsecutiveCalls($wikiId, $siteName));
     $mainPageTitle = $this->getMock('GlobalTitle', array(), array(), '', false);
     $mainPageTitle->expects($this->once())->method('getFullURL')->will($this->returnValue($mainPageUrl));
     F::setInstance('CreateWiki', $createWiki);
     F::setInstance('GlobalTitle', $mainPageTitle);
     $wgUser = $this->getMock('User');
     $response = $app->sendRequest('CreateNewWiki', 'CreateWiki');
     $this->assertEquals("ok", $response->getVal('status'));
     $this->assertEquals($siteName, $response->getVal('siteName'));
     $this->assertEquals($mainPageUrl, $response->getval('finishCreateUrl'));
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:34,代码来源:CreateNewWikiControllerTest.php

示例7: __construct

 function __construct()
 {
     parent::__construct();
     if (!self::$initialized) {
         //singleton
         F::setInstance(__CLASS__, $this);
         self::$initialized = true;
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:9,代码来源:WikiaMobileService.class.php

示例8: __construct

 public function __construct($name = null, $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false)
 {
     if ($name == null) {
         throw new WikiaException('First parameter of WikiaSpecialPage constructor must not be null');
     }
     $this->specialPage = F::build('SpecialPage', array($name, $restriction, $listed, $function, $file, $includable));
     F::setInstance(get_class($this), $this);
     parent::__construct();
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:9,代码来源:WikiaSpecialPageController.class.php

示例9: getInstance

 /**
  * Returns the singleton instance
  *
  * @return PathFinderLogger singleton instance
  */
 public static function getInstance()
 {
     $class = get_called_class();
     $instance = F::getInstance($class);
     if (empty($instance)) {
         $instance = F::build($class);
         F::setInstance($class, $instance);
     }
     return $instance;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:15,代码来源:PathFinderLogger.class.php

示例10: testIsConfigSetup

 /**
  * @dataProvider isConfigSetupDataProvider
  */
 public function testIsConfigSetup($expected, $fbAppId, $fbAppSecret)
 {
     $this->fbAppId = $fbAppId;
     $this->fbAppSecret = $fbAppSecret;
     $app = $this->getMock('WikiaApp', array('getGlobal'));
     $app->expects($this->any())->method('getGlobal')->will($this->returnCallback(array($this, 'isConfigSetupGlobalsCallback')));
     F::setInstance('App', $app);
     $result = FBConnectAPI::isConfigSetup();
     $this->assertEquals($expected, $result);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:13,代码来源:FBConnectAPITest.php

示例11: setUpToggleFeature

 protected function setUpToggleFeature($is_allow)
 {
     global $wgWikicitiesReadOnly;
     $this->wgWikicitiesReadOnly_org = $wgWikicitiesReadOnly;
     $wgWikicitiesReadOnly = true;
     $mock_log = $this->getMock('LogPage', array('addEntry'), array(), '', false);
     $mock_log->expects($this->any())->method('addEntry');
     F::setInstance('LogPage', $mock_log);
     $mock_user = $this->getMock('User', array('isAllowed'));
     $mock_user->expects($this->any())->method('isAllowed')->will($this->returnValue($is_allow));
     $this->mockGlobalVariable('wgUser', $mock_user);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:12,代码来源:WikiFeaturesTest.php

示例12: mockDatabaseResponse

 public function mockDatabaseResponse($isEmpty = false)
 {
     $fakeRow = $isEmpty ? array() : $this->getFakeRow();
     $db = $this->getMock('DatabaseMysql');
     $db->expects($this->any())->method('selectRow')->will($this->returnValue($fakeRow));
     $games = $this->getMock('ScavengerHuntGames', array('getDb'), array($this->app));
     $games->expects($this->any())->method('getDb')->will($this->returnValue($db));
     $this->mockClass('ScavengerHuntGames', $games);
     // This is necessary because Game->setLandingTitle is called during construction
     // and it resets the landingArticleWikiId and landingArticleName to bogus values otherwise
     F::setInstance('GlobalTitle', array('wikiId' => self::LANDING_WIKI_ID, 'articleName' => self::MOCK_TEXT));
     return $games;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:13,代码来源:ScavengerHuntTest.php

示例13: __construct

 function __construct()
 {
     if (empty(self::$instanciated)) {
         self::$instanciated = true;
         F::setInstance(__CLASS__, $this);
         $this->register('FacebookSharing');
         $this->register('TwitterSharing');
         $this->register('PlusoneSharing');
         $this->register('StumbleuponSharing');
         $this->register('RedditSharing');
         $this->register('EmailSharing');
     }
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:13,代码来源:SocialSharingService.class.php

示例14: setupGetStatsMock

 protected function setupGetStatsMock($cache_value, $fetch_obj)
 {
     $mock_cache = $this->getMock('stdClass', array('get', 'set', 'delete'));
     $mock_cache->expects($this->any())->method('get')->will($this->returnValue($cache_value));
     $mock_cache->expects($this->any())->method('set');
     $mock_cache->expects($this->any())->method('delete');
     if (!is_null($fetch_obj)) {
         $this->setMockDb($fetch_obj);
     }
     $mock = $this->getMock('QuickStatsController', array('getDailyLikes'));
     $mock->expects($this->any())->method('getDailyLikes')->will($this->returnValue(false));
     F::setInstance('QuickStatsController', $mock);
     $this->mockGlobalVariable('wgCityId', self::TEST_CITY_ID);
     $this->mockGlobalVariable('wgMemc', $mock_cache, 0);
     $this->mockGlobalFunction('wfMemcKey', null, 0);
     $this->mockApp();
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:17,代码来源:AdminDashboardTest.php

示例15: init

 public function init()
 {
     $wikiaAppArgs = array();
     $globalRegistryMock = null;
     $functionWrapperMock = null;
     $globalRegistryMock = $this->testCase->getMock('WikiaGlobalRegistry', array('get', 'set'));
     $globalRegistryMock->expects($this->testCase->any())->method('get')->will($this->testCase->returnCallback(array($this, 'getGlobalCallback')));
     if (in_array('runFunction', $this->methods)) {
         $functionWrapperMock = $this->testCase->getMock('WikiaFunctionWrapper', array_keys($this->mockedFunctions));
         foreach ($this->mockedFunctions as $functionName => $functionData) {
             $functionWrapperMock->expects($this->testCase->exactly($functionData['calls']))->method($functionName)->will($this->testCase->returnValue($functionData['value']));
         }
     }
     $wikiaAppArgs[] = $globalRegistryMock;
     $wikiaAppArgs[] = null;
     // WikiaLocalRegistry
     $wikiaAppArgs[] = null;
     // WikiaHookDispatcher
     $wikiaAppArgs[] = $functionWrapperMock;
     $this->mock = $this->testCase->getMock('WikiaApp', array('ajax'), $wikiaAppArgs, '');
     F::setInstance('App', $this->mock);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:22,代码来源:WikiaAppMock.class.php


注:本文中的F::setInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。