Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 16, 2018
2 parents 530a835 + a47b50a commit 8f89eac
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/Illuminate/Auth/RequestGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ public function validate(array $credentials = [])
*/
public function setRequest(Request $request)
{
$this->user = null;

$this->request = $request;

return $this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

namespace Illuminate\Tests\Integration\Foundation\Testing\Concerns;

use Illuminate\Http\Request;
use Orchestra\Testbench\TestCase;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Schema;
use Illuminate\Foundation\Auth\User as Authenticatable;

class InteractsWithAuthenticationTest extends TestCase
{
protected function getEnvironmentSetUp($app)
{
$app['config']->set('auth.providers.users.model', AuthenticationTestUser::class);

$app['config']->set('database.default', 'testbench');
$app['config']->set('database.connections.testbench', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
}

public function setUp()
{
parent::setUp();

Schema::create('users', function ($table) {
$table->increments('id');
$table->string('email');
$table->string('username');
$table->string('password');
$table->string('remember_token')->default(null)->nullable();
$table->tinyInteger('is_active')->default(0);
});

AuthenticationTestUser::create([
'username' => 'taylorotwell',
'email' => 'taylorotwell@laravel.com',
'password' => bcrypt('password'),
'is_active' => true,
]);
}

public function test_acting_as_is_properly_handled_for_session_auth()
{
Route::get('me', function (Request $request) {
return 'Hello '.$request->user()->username;
})->middleware(['auth']);

$user = AuthenticationTestUser::where('username', '=', 'taylorotwell')->first();

$this->actingAs($user)
->get('/me')
->assertSuccessful()
->assertSeeText('Hello taylorotwell');
}

public function test_acting_as_is_properly_handled_for_auth_via_request()
{
Route::get('me', function (Request $request) {
return 'Hello '.$request->user()->username;
})->middleware(['auth:api']);

Auth::viaRequest('api', function ($request) {
return $request->user();
});

$user = AuthenticationTestUser::where('username', '=', 'taylorotwell')->first();

$this->actingAs($user, 'api')
->get('/me')
->assertSuccessful()
->assertSeeText('Hello taylorotwell');
}
}

class AuthenticationTestUser extends Authenticatable
{
public $table = 'users';
public $timestamps = false;

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $guarded = ['id'];

/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
3 changes: 1 addition & 2 deletions tests/Support/SupportCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -984,11 +984,10 @@ public function testExcept()

$this->assertEquals(['first' => 'Taylor'], $data->except(['last', 'email', 'missing'])->all());
$this->assertEquals(['first' => 'Taylor'], $data->except('last', 'email', 'missing')->all());
$this->assertEquals(['first' => 'Taylor'], $data->except(collect(['last', 'email', 'missing']))->all());

$this->assertEquals(['first' => 'Taylor'], $data->except(collect(['last', 'email', 'missing']))->all());
$this->assertEquals(['first' => 'Taylor', 'email' => 'taylorotwell@gmail.com'], $data->except(['last'])->all());
$this->assertEquals(['first' => 'Taylor', 'email' => 'taylorotwell@gmail.com'], $data->except('last')->all());
$this->assertEquals(['first' => 'Taylor', 'email' => 'taylorotwell@gmail.com'], $data->except(collect(['last']))->all());
}

public function testPluckWithArrayAndObjectValues()
Expand Down

0 comments on commit 8f89eac

Please sign in to comment.