本文整理匯總了PHP中Piwik\API\Proxy::call方法的典型用法代碼示例。如果您正苦於以下問題:PHP Proxy::call方法的具體用法?PHP Proxy::call怎麽用?PHP Proxy::call使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Piwik\API\Proxy
的用法示例。
在下文中一共展示了Proxy::call方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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);
}