本文整理汇总了PHP中Piwik\Tests\Framework\Mock\FakeAccess::identity方法的典型用法代码示例。如果您正苦于以下问题:PHP FakeAccess::identity方法的具体用法?PHP FakeAccess::identity怎么用?PHP FakeAccess::identity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Tests\Framework\Mock\FakeAccess
的用法示例。
在下文中一共展示了FakeAccess::identity方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUser
protected function setUser()
{
FakeAccess::$superUser = false;
FakeAccess::$idSitesAdmin = array();
FakeAccess::$idSitesView = array(99);
FakeAccess::$identity = 'aUser';
}
示例2: test_getSitesIdFromSiteUrl_asUser
public function test_getSitesIdFromSiteUrl_asUser()
{
API::getInstance()->addSite("site1", array("http://www.piwik.net", "https://piwik.com"));
API::getInstance()->addSite("site2", array("http://piwik.com", "http://piwik.net"));
API::getInstance()->addSite("site3", array("http://piwik.com", "http://piwik.org"));
APIUsersManager::getInstance()->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias");
APIUsersManager::getInstance()->setUserAccess("user1", "view", array(1));
APIUsersManager::getInstance()->addUser("user2", "geqgegagae", "tegst2@tesgt.com", "alias");
APIUsersManager::getInstance()->setUserAccess("user2", "view", array(1));
APIUsersManager::getInstance()->setUserAccess("user2", "admin", array(3));
APIUsersManager::getInstance()->addUser("user3", "geqgegagae", "tegst3@tesgt.com", "alias");
APIUsersManager::getInstance()->setUserAccess("user3", "view", array(1, 2));
APIUsersManager::getInstance()->setUserAccess("user3", "admin", array(3));
FakeAccess::$superUser = false;
FakeAccess::$identity = 'user1';
FakeAccess::setIdSitesView(array(1));
FakeAccess::setIdSitesAdmin(array());
$this->assertFalse(Piwik::hasUserSuperUserAccess());
$idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
$this->assertEquals(1, count($idsites));
// testing URL normalization
$idsites = API::getInstance()->getSitesIdFromSiteUrl('http://www.piwik.com');
$this->assertEquals(1, count($idsites));
$idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
$this->assertEquals(1, count($idsites));
FakeAccess::$superUser = false;
FakeAccess::$identity = 'user2';
FakeAccess::setIdSitesView(array(1));
FakeAccess::setIdSitesAdmin(array(3));
$idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
$this->assertEquals(2, count($idsites));
FakeAccess::$superUser = false;
FakeAccess::$identity = 'user3';
FakeAccess::setIdSitesView(array(1, 2));
FakeAccess::setIdSitesAdmin(array(3));
$idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
$this->assertEquals(3, count($idsites));
$idsites = API::getInstance()->getSitesIdFromSiteUrl('https://www.piwik.com');
$this->assertEquals(3, count($idsites));
}
示例3: setNonAdminUser
protected function setNonAdminUser()
{
FakeAccess::setSuperUserAccess(false);
FakeAccess::$idSitesView = array(99);
FakeAccess::$identity = 'aUser';
}
示例4: setAnonymous
private function setAnonymous()
{
FakeAccess::clearAccess();
FakeAccess::$identity = 'anonymous';
}
示例5: setIdentity
private function setIdentity($login)
{
FakeAccess::$identity = $login;
FakeAccess::$superUser = true;
}
示例6: test_getTriggeredAlerts_ShouldReturnAllThatMatchesLoginAndIdSite
public function test_getTriggeredAlerts_ShouldReturnAllThatMatchesLoginAndIdSite()
{
$idSite = 1;
$this->setSuperUser();
$this->model->triggerAlert(2, $idSite, 99, 48, Date::now()->getDatetime());
$triggeredAlerts = $this->api->getTriggeredAlerts(array($idSite));
$this->assertCount(1, $triggeredAlerts);
$triggeredAlerts = $this->api->getTriggeredAlerts(array($idSite, 2));
$this->assertCount(1, $triggeredAlerts);
// no matching site
$triggeredAlerts = $this->api->getTriggeredAlerts(array(2));
$this->assertCount(0, $triggeredAlerts);
// different login
FakeAccess::$identity = 'differentLoginButStillSuperuser';
$triggeredAlerts = $this->api->getTriggeredAlerts(array($idSite, 2));
$this->assertCount(0, $triggeredAlerts);
// different login
$this->setUser();
FakeAccess::$idSitesView = array(1);
$triggeredAlerts = $this->api->getTriggeredAlerts(array(1));
$this->assertCount(0, $triggeredAlerts);
}
示例7: setAnonymousUser
protected function setAnonymousUser()
{
FakeAccess::clearAccess();
FakeAccess::$identity = 'anonymous';
}
示例8: testUpdateUserIAmNotTheUser
/**
* check to modify as being another user => exception
*
* @expectedException \Exception
*/
public function testUpdateUserIAmNotTheUser()
{
FakeAccess::$identity = 'login2';
FakeAccess::$superUser = false;
$this->testUpdateUserNoEmailNoAlias();
}
示例9: setUser
private function setUser()
{
FakeAccess::$idSitesView = array(1);
FakeAccess::$identity = 'userLogin';
$this->createSettings();
}
示例10: FakeAccess
}
}), 'Piwik\\Access' => DI\decorate(function ($previous, ContainerInterface $c) {
$testUseMockAuth = $c->get('test.vars.testUseMockAuth');
if ($testUseMockAuth) {
$idSitesAdmin = $c->get('test.vars.idSitesAdminAccess');
$idSitesView = $c->get('test.vars.idSitesViewAccess');
$access = new FakeAccess();
if (!empty($idSitesView)) {
FakeAccess::$superUser = false;
FakeAccess::$idSitesView = $idSitesView;
FakeAccess::$idSitesAdmin = !empty($idSitesAdmin) ? $idSitesAdmin : array();
FakeAccess::$identity = 'viewUserLogin';
} elseif (!empty($idSitesAdmin)) {
FakeAccess::$superUser = false;
FakeAccess::$idSitesAdmin = $idSitesAdmin;
FakeAccess::$identity = 'adminUserLogin';
} else {
FakeAccess::$superUser = true;
FakeAccess::$superUserLogin = 'superUserLogin';
}
return $access;
} else {
return $previous;
}
}), 'observers.global' => DI\add(array(array('AssetManager.getStylesheetFiles', function (&$stylesheets) {
$useOverrideCss = \Piwik\Container\StaticContainer::get('test.vars.useOverrideCss');
if ($useOverrideCss) {
$stylesheets[] = 'tests/resources/screenshot-override/override.css';
}
}), array('AssetManager.getJavaScriptFiles', function (&$jsFiles) {
$useOverrideJs = \Piwik\Container\StaticContainer::get('test.vars.useOverrideJs');