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


PHP Proxy::setSingletonInstance方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     parent::setUp();
     $self = $this;
     $proxyMock = $this->getMock('stdClass', array('call'));
     $proxyMock->expects($this->any())->method('call')->willReturnCallback(function ($className, $methodName, $parameters) use($self) {
         if ($className == "\\Piwik\\Plugins\\UserCountry\\API" && $methodName == 'getCity') {
             $self->segmentUsedToGetIntersected[] = $parameters['segment'];
             return $self->getSegmentTable();
         } else {
             throw new Exception("Unknown API request: {$className}::{$methodName}.");
         }
     });
     Proxy::setSingletonInstance($proxyMock);
     $this->segmentTableCount = 0;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:16,代码来源:PivotByDimensionTest.php

示例2: test_fetchSubtable_ShouldUseCorrectApiUrl

 public function test_fetchSubtable_ShouldUseCorrectApiUrl()
 {
     PluginManager::getInstance()->loadPlugins(array('API', 'Referrers'));
     $proxyMock = $this->getMock('stdClass', array('call', '__construct'));
     $proxyMock->expects($this->once())->method('call')->with('\\Piwik\\Plugins\\Referrers\\API', 'getSearchEnginesFromKeywordId', array('idSubtable' => 23, 'idSite' => 1, 'date' => '2012-01-02', 'format' => 'original', 'module' => 'API', 'method' => 'Referrers.getSearchEnginesFromKeywordId'))->willReturn("result");
     Proxy::setSingletonInstance($proxyMock);
     $report = new \Piwik\Plugins\Referrers\Reports\GetKeywords();
     $result = $report->fetchSubtable(23, array('idSite' => 1, 'date' => '2012-01-02'));
     $this->assertEquals("result", $result);
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:10,代码来源:ReportTest.php

示例3: test_generateReport_CatchesIndividualReportProcessExceptions_WithoutFailingToGenerateWholeReport

 public function test_generateReport_CatchesIndividualReportProcessExceptions_WithoutFailingToGenerateWholeReport()
 {
     $realProxy = new Proxy();
     $mockProxy = $this->getMock('Piwik\\API\\Proxy', array('call'));
     $mockProxy->expects($this->any())->method('call')->willReturnCallback(function ($className, $methodName, $parametersRequest) use($realProxy) {
         switch ($className) {
             case '\\Piwik\\Plugins\\VisitsSummary\\API':
                 $result = new DataTable();
                 $result->addRowFromSimpleArray(array('label' => 'visits label', 'nb_visits' => 1));
                 return $result;
             case '\\Piwik\\Plugins\\UserCountry\\API':
                 throw new \Exception("error");
             case '\\Piwik\\Plugins\\Referrers\\API':
                 $result = new DataTable();
                 $result->addRowFromSimpleArray(array('label' => 'referrers label', 'nb_visits' => 1));
                 return $result;
             case '\\Piwik\\Plugins\\API\\API':
                 return $realProxy->call($className, $methodName, $parametersRequest);
             default:
                 throw new \Exception("Unexpected method {$className}::{$methodName}.");
         }
     });
     Proxy::setSingletonInstance($mockProxy);
     $idReport = APIScheduledReports::getInstance()->addReport(1, '', Schedule::PERIOD_DAY, 0, ScheduledReports::EMAIL_TYPE, ReportRenderer::HTML_FORMAT, array('VisitsSummary_get', 'UserCountry_getCountry', 'Referrers_getWebsites'), array(ScheduledReports::DISPLAY_FORMAT_PARAMETER => ScheduledReports::DISPLAY_FORMAT_TABLES_ONLY));
     ob_start();
     $result = APIScheduledReports::getInstance()->generateReport($idReport, Date::factory('now')->toString(), $language = false, $outputType = APIScheduledReports::OUTPUT_RETURN);
     ob_end_clean();
     $this->assertContains('id="VisitsSummary_get"', $result);
     $this->assertContains('id="Referrers_getWebsites"', $result);
     $this->assertNotContains('id="UserCountry_getCountry"', $result);
 }
开发者ID:JoeHorn,项目名称:piwik,代码行数:31,代码来源:ApiTest.php


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