當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Site::setSites方法代碼示例

本文整理匯總了PHP中Piwik\Site::setSites方法的典型用法代碼示例。如果您正苦於以下問題:PHP Site::setSites方法的具體用法?PHP Site::setSites怎麽用?PHP Site::setSites使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Piwik\Site的用法示例。


在下文中一共展示了Site::setSites方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetUnit

 /**
  * @dataProvider getUnitColumns
  * @group Core
  */
 public function testGetUnit($column, $expected)
 {
     Site::setSites(array(1 => array('name' => 'TestSite', 'currency' => 'EUR')));
     FakeAccess::$superUser = true;
     $actual = Metrics::getUnit($column, 1);
     $this->assertEquals($expected, $actual);
 }
開發者ID:mgou-net,項目名稱:piwik,代碼行數:11,代碼來源:MetricsTest.php

示例2: testGetUnit

 /**
  * @dataProvider getUnitColumns
  * @group Core
  */
 public function testGetUnit($column, $expected)
 {
     \Piwik\Site::setSites(array(1 => array('name' => 'TestSite', 'currency' => 'EUR')));
     $pseudoMockAccess = new FakeAccess();
     FakeAccess::$superUser = true;
     Access::setSingletonInstance($pseudoMockAccess);
     $actual = Metrics::getUnit($column, 1);
     $this->assertEquals($expected, $actual);
 }
開發者ID:a4tunado,項目名稱:piwik,代碼行數:13,代碼來源:MetricsTest.php

示例3: testGetScheduledTasks

 /**
  * @group Plugins
  */
 public function testGetScheduledTasks()
 {
     // stub API to control getReports() return values
     $report1 = self::getDailyPDFReportData($this->idSite);
     $report1['idreport'] = 1;
     $report1['hour'] = 0;
     $report1['deleted'] = 0;
     $report2 = self::getMonthlyEmailReportData($this->idSite);
     $report2['idreport'] = 2;
     $report2['idsite'] = 2;
     $report2['hour'] = 0;
     $report2['deleted'] = 0;
     $report3 = self::getMonthlyEmailReportData($this->idSite);
     $report3['idreport'] = 3;
     $report3['deleted'] = 1;
     // should not be scheduled
     $report4 = self::getMonthlyEmailReportData($this->idSite);
     $report4['idreport'] = 4;
     $report4['idsite'] = 1;
     $report4['hour'] = 8;
     $report4['deleted'] = 0;
     $report5 = self::getMonthlyEmailReportData($this->idSite);
     $report5['idreport'] = 5;
     $report5['idsite'] = 2;
     $report5['hour'] = 8;
     $report5['deleted'] = 0;
     // test no exception is raised when a scheduled report is set to never send
     $report6 = self::getMonthlyEmailReportData($this->idSite);
     $report6['idreport'] = 6;
     $report6['period'] = Schedule::PERIOD_NEVER;
     $report6['deleted'] = 0;
     $stubbedAPIScheduledReports = $this->getMock('\\Piwik\\Plugins\\ScheduledReports\\API', array('getReports', 'getInstance'), $arguments = array(), $mockClassName = '', $callOriginalConstructor = false);
     $stubbedAPIScheduledReports->expects($this->any())->method('getReports')->will($this->returnValue(array($report1, $report2, $report3, $report4, $report5, $report6)));
     \Piwik\Plugins\ScheduledReports\API::setSingletonInstance($stubbedAPIScheduledReports);
     // initialize sites 1 and 2
     Site::setSites(array(1 => array('timezone' => 'Europe/Paris'), 2 => array('timezone' => 'UTC-6.5')));
     // expected tasks
     $scheduleTask1 = Schedule::factory('daily');
     $scheduleTask1->setHour(0);
     // paris is UTC-1, period ends at 23h UTC
     $scheduleTask1->setTimezone('Europe/Paris');
     $scheduleTask2 = new Monthly();
     $scheduleTask2->setHour(0);
     // site is UTC-6.5, period ends at 6h30 UTC, smallest resolution is hour
     $scheduleTask2->setTimezone('UTC-6.5');
     $scheduleTask3 = new Monthly();
     $scheduleTask3->setHour(8);
     // paris is UTC-1, configured to be sent at 8h
     $scheduleTask3->setTimezone('Europe/Paris');
     $scheduleTask4 = new Monthly();
     $scheduleTask4->setHour(8);
     // site is UTC-6.5, configured to be sent at 8h
     $scheduleTask4->setTimezone('UTC-6.5');
     $expectedTasks = array(new Task(APIScheduledReports::getInstance(), 'sendReport', 1, $scheduleTask1), new Task(APIScheduledReports::getInstance(), 'sendReport', 2, $scheduleTask2), new Task(APIScheduledReports::getInstance(), 'sendReport', 4, $scheduleTask3), new Task(APIScheduledReports::getInstance(), 'sendReport', 5, $scheduleTask4));
     $pdfReportPlugin = new Tasks();
     $pdfReportPlugin->schedule();
     $tasks = $pdfReportPlugin->getScheduledTasks();
     $this->assertEquals($expectedTasks, $tasks);
     \Piwik\Plugins\ScheduledReports\API::unsetInstance();
 }
開發者ID:JoeHorn,項目名稱:piwik,代碼行數:63,代碼來源:ApiTest.php


注:本文中的Piwik\Site::setSites方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。