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


PHP Sentry::setUser方法代碼示例

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


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

示例1: beAdmin

 /**
  * Impersonate an admin
  *
  */
 public function beAdmin()
 {
     $admin = Sentry::findUserByLogin('admin@admin.com');
     Sentry::setUser($admin);
     Session::put('userId', 1);
     Session::put('email', 'admin@admin.com');
 }
開發者ID:jacobDaeHyung,項目名稱:Laravel-Real-Estate-Manager,代碼行數:11,代碼來源:TestCase.php

示例2: setUp

 public function setUp()
 {
     Illuminate\Foundation\Testing\TestCase::setUp();
     Artisan::call('migrate', array('--package' => 'cartalyst\\sentry'));
     // 		Artisan::call('migrate');
     Artisan::call('migrate', array('--package' => 'rtconner\\laravel-addresses'));
     Artisan::call('db:seed', array('--class' => 'Conner\\Addresses\\DatabaseSeeder'));
     $user = new \Cartalyst\Sentry\Users\Eloquent\User();
     $user->id = 1;
     \Sentry::setUser($user);
 }
開發者ID:declum,項目名稱:laravel-addresses,代碼行數:11,代碼來源:AddressesTest.php

示例3: testBasicUserTypes

 /**
  * Test the two basic user types
  *
  */
 public function testBasicUserTypes()
 {
     $this->assertTrue(Sentry::getUser() == NULL, 'User should not be logged in initially.');
     $admin = Sentry::findUserByLogin($this->adminEmail);
     $this->assertTrue($admin != NULL, 'Admin account not found.');
     $user = Sentry::findUserByLogin($this->userEmail);
     $this->assertTrue($user != NULL, 'User account not found.');
     Sentry::setUser($user);
     $this->assertTrue(Sentry::check(), 'User not logged in.');
     Sentry::setUser($admin);
     $this->assertTrue(Sentry::check(), 'Admin not logged in.');
     Sentry::logout();
 }
開發者ID:marmaray,項目名稱:L4withSentry,代碼行數:17,代碼來源:UserControllerTest.php

示例4: testUpdatingUserWithAdditionalData

 /**
  * Update a user without referencing the username
  */
 public function testUpdatingUserWithAdditionalData()
 {
     // Explicitly set the 'additional user fields'
     app()['config']->set('sentinel.additional_user_fields', ['first_name' => 'alpha_spaces', 'last_name' => 'alpha_spaces']);
     // Find the user we are going to update
     $user = Sentry::findUserByLogin('user@user.com');
     // Find the admin user we are going to impersonate
     $admin = Sentry::findUserByLogin('admin@admin.com');
     Sentry::setUser($admin);
     // This is the code we are testing
     $result = $this->repo->update(['id' => $user->id, 'first_name' => 'Irina', 'last_name' => 'Prozorova', 'email' => 'irina@prozorov.net']);
     // Assertions
     $this->assertInstanceOf('Sentinel\\Models\\User', $user);
     $this->assertInstanceOf('Sentinel\\Models\\User', $result->getPayload()['user']);
     $this->assertTrue($result->isSuccessful());
     $testUser = DB::table('users')->where('id', $user->id)->where('first_name', 'Irina')->where('last_name', 'Prozorova')->where('email', 'irina@prozorov.net')->first();
     $this->assertEquals('irina@prozorov.net', $testUser->email);
 }
開發者ID:acmadi,項目名稱:integrasi,代碼行數:21,代碼來源:SentryUserRepositoryTests.php

示例5: beAdmin

 /**
  * Impersonate an admin
  *
  */
 public function beAdmin()
 {
     $admin = Sentry::findUserByLogin($this->adminEmail);
     Sentry::setUser($admin);
     Session::put('userId', 1);
     Session::put('email', $this->adminEmail);
 }
開發者ID:marmaray,項目名稱:L4withSentry,代碼行數:11,代碼來源:TestCase.php

示例6: beAdmin

 /**
  * Impersonate an admin
  *
  */
 public function beAdmin()
 {
     $admin = Sentry::findUserByLogin($this->adminEmail);
     Sentry::setUser($admin);
 }
開發者ID:Adamiko,項目名稱:lama,代碼行數:9,代碼來源:TestCase.php


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