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


PHP User::delete方法代碼示例

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


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

示例1: testSwitchUserListItems

 /**
  * Test the user list items.
  */
 public function testSwitchUserListItems()
 {
     $anonymous = \Drupal::config('user.settings')->get('anonymous');
     $this->setBlockConfiguration('list_size', 2);
     // Login as web user so we are sure that this account is prioritized
     // in the list if not enougth user with 'switch users' permission are
     // present.
     $this->drupalLogin($this->webUser);
     $this->drupalLogin($this->develUser);
     $this->drupalGet('');
     // Ensure that user with 'switch users' permission are prioritized.
     $this->assertSwitchUserListCount(2);
     $this->assertSwitchUserListContainsUser($this->develUser->getUsername());
     $this->assertSwitchUserListContainsUser($this->switchUser->getUsername());
     // Ensure that blocked users are not shown in the list.
     $this->switchUser->set('status', 0)->save();
     $this->drupalGet('');
     $this->assertSwitchUserListCount(2);
     $this->assertSwitchUserListContainsUser($this->develUser->getUsername());
     $this->assertSwitchUserListContainsUser($this->webUser->getUsername());
     $this->assertSwitchUserListNoContainsUser($this->switchUser->getUsername());
     // Ensure that anonymous user are prioritized if include_anon is set to true.
     $this->setBlockConfiguration('include_anon', TRUE);
     $this->drupalGet('');
     $this->assertSwitchUserListCount(2);
     $this->assertSwitchUserListContainsUser($this->develUser->getUsername());
     $this->assertSwitchUserListContainsUser($anonymous);
     // Ensure that the switch user block works properly even if no prioritized
     // users are found (special handling for user 1).
     $this->drupalLogout();
     $this->develUser->delete();
     $this->drupalLogin($this->rootUser);
     $this->drupalGet('');
     $this->assertSwitchUserListCount(2);
     $this->assertSwitchUserListContainsUser($this->rootUser->getUsername());
     $this->assertSwitchUserListContainsUser($anonymous);
     // Ensure that the switch user block works properly even if no roles have
     // the 'switch users' permission associated (special handling for user 1).
     $roles = user_roles(TRUE, 'switch users');
     \Drupal::entityTypeManager()->getStorage('user_role')->delete($roles);
     $this->drupalGet('');
     $this->assertSwitchUserListCount(2);
     $this->assertSwitchUserListContainsUser($this->rootUser->getUsername());
     $this->assertSwitchUserListContainsUser($anonymous);
 }
開發者ID:sedurzu,項目名稱:ildeposito8,代碼行數:48,代碼來源:DevelSwitchUserTest.php


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