本文整理汇总了PHP中Piwik\Access::setSingletonInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Access::setSingletonInstance方法的具体用法?PHP Access::setSingletonInstance怎么用?PHP Access::setSingletonInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Access
的用法示例。
在下文中一共展示了Access::setSingletonInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAnnotations
private function addAnnotations()
{
// create fake access for fake username
$access = new FakeAccess();
FakeAccess::$superUser = true;
Access::setSingletonInstance($access);
// add two annotations per week for three months, starring every third annotation
// first month in 2011, second two in 2012
$count = 0;
$dateStart = Date::factory('2011-12-01');
$dateEnd = Date::factory('2012-03-01');
while ($dateStart->getTimestamp() < $dateEnd->getTimestamp()) {
$starred = $count % 3 == 0 ? 1 : 0;
$site1Text = "{$count}: Site 1 annotation for " . $dateStart->toString();
$site2Text = "{$count}: Site 2 annotation for " . $dateStart->toString();
API::getInstance()->add($this->idSite1, $dateStart->toString(), $site1Text, $starred);
API::getInstance()->add($this->idSite2, $dateStart->toString(), $site2Text, $starred);
$nextDay = $dateStart->addDay(1);
++$count;
$starred = $count % 3 == 0 ? 1 : 0;
$site1Text = "{$count}: Site 1 annotation for " . $nextDay->toString();
$site2Text = "{$count}: Site 2 annotation for " . $nextDay->toString();
API::getInstance()->add($this->idSite1, $nextDay->toString(), $site1Text, $starred);
API::getInstance()->add($this->idSite2, $nextDay->toString(), $site2Text, $starred);
$dateStart = $dateStart->addPeriod(1, 'WEEK');
++$count;
}
}
示例2: setUp
public function setUp()
{
parent::setUp();
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
}
示例3: setUp
public function setUp()
{
parent::setUp();
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
\Piwik\Plugin\Manager::getInstance()->loadPlugins(array('SitesManager'));
}
示例4: setUp
public function setUp()
{
parent::setUp();
$pseudoMockAccess = new \FakeAccess();
\FakeAccess::setSuperUserAccess(true);
Access::setSingletonInstance($pseudoMockAccess);
$idSite = Fixture::createWebsite('2014-01-01 00:00:00');
$this->builder = $this->makeBuilder(array('method' => 'MultiSites_getAll', 'idSite' => $idSite));
}
示例5: 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);
}
示例6: setUp
public function setUp()
{
parent::setUp();
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
//finally we set the user as a Super User by default
Access::setSingletonInstance($pseudoMockAccess);
$this->idSiteAccess = APISitesManager::getInstance()->addSite("test", "http://test");
\Piwik\Plugin\Manager::getInstance()->loadPlugins(array('ScheduledReports', 'MobileMessaging', 'MultiSites'));
\Piwik\Plugin\Manager::getInstance()->installLoadedPlugins();
}
示例7: setUp
public function setUp()
{
parent::setUp();
$this->api = API::getInstance();
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
Fixture::createWebsite('2014-01-01 00:00:00');
Fixture::createWebsite('2014-01-01 00:00:00');
Fixture::createWebsite('2014-01-01 00:00:00');
$this->api->addUser('userLogin', 'password', 'userlogin@password.de');
}
示例8: setUp
public function setUp()
{
parent::setUp();
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::setIdSitesView(array(1, 2));
FakeAccess::setIdSitesAdmin(array(3, 4));
//finally we set the user as a Super User by default
FakeAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
$this->auth = new Auth();
}
示例9: setUp
public function setUp()
{
parent::setUp();
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::setIdSitesView(array(1, 2));
FakeAccess::setIdSitesAdmin(array(3, 4));
//finally we set the user as a Super User by default
FakeAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
$user_agents = array('Mozilla/6.0 (Macintosh; I; Intel Mac OS X 11_7_9; de-LI; rv:1.9b4) Gecko/2012010317 Firefox/10.0a4', 'Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/18.6.872.0 Safari/535.2 UNTRUSTED/1.0 3gpp-gba UNTRUSTED/1.0', 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1');
$_SERVER['HTTP_USER_AGENT'] = $user_agents[mt_rand(0, count($user_agents) - 1)];
}
示例10: setUp
public function setUp()
{
parent::setUp();
\Piwik\Plugin\Manager::getInstance()->loadPlugin('SegmentEditor');
\Piwik\Plugin\Manager::getInstance()->installLoadedPlugins();
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::setIdSitesView(array(1, 2));
FakeAccess::setIdSitesAdmin(array(3, 4));
//finally we set the user as a Super User by default
FakeAccess::$superUser = true;
FakeAccess::$superUserLogin = 'superusertest';
Access::setSingletonInstance($pseudoMockAccess);
APISitesManager::getInstance()->addSite('test', 'http://example.org');
}
示例11: setUp
public function setUp()
{
parent::setUp();
\Piwik\Plugin\Manager::getInstance()->loadPlugin('UsersManager');
\Piwik\Plugin\Manager::getInstance()->installLoadedPlugins();
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::setIdSitesView(array(1, 2));
FakeAccess::setIdSitesAdmin(array(3, 4));
//finally we set the user as a Super User by default
FakeAccess::$superUser = true;
FakeAccess::$superUserLogin = 'superusertest';
Access::setSingletonInstance($pseudoMockAccess);
$this->api = API::getInstance();
$this->model = new Model();
}
示例12: setNonAdminUser
protected function setNonAdminUser()
{
$pseudoMockAccess = new \FakeAccess();
\FakeAccess::setSuperUserAccess(false);
\FakeAccess::$idSitesView = array(99);
\FakeAccess::$identity = 'aUser';
Access::setSingletonInstance($pseudoMockAccess);
}
示例13: testMethodPermissions
/**
* @dataProvider getPermissionsFailData
* @group Integration
*/
public function testMethodPermissions($hasAdminAccess, $hasViewAccess, $request, $checkException, $failMessage)
{
// create fake access that denies user access
$access = new FakeAccess();
FakeAccess::$superUser = false;
FakeAccess::$idSitesAdmin = $hasAdminAccess ? array(self::$fixture->idSite1) : array();
FakeAccess::$idSitesView = $hasViewAccess ? array(self::$fixture->idSite1) : array();
Access::setSingletonInstance($access);
if ($checkException) {
try {
$request = new Request($request);
$request->process();
$this->fail($failMessage);
} catch (Exception $ex) {
// pass
}
} else {
$request = new Request($request);
$response = $request->process();
}
}
示例14: setIdentity
private function setIdentity($login)
{
$pseudoMockAccess = new \FakeAccess();
$pseudoMockAccess::$identity = $login;
$pseudoMockAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
}
示例15: setAnonymous
private function setAnonymous()
{
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = false;
Access::setSingletonInstance($pseudoMockAccess);
}