Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Illuminate\Tests\Integration\Foundation\Testing\Concerns; use Illuminate..
Decoded Output download
<?php
namespace Illuminate\Tests\Integration\Foundation\Testing\Concerns;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Foundation\Auth\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\TestCase;
#[WithMigration]
class InteractsWithAuthenticationTest extends TestCase
{
use RefreshDatabase;
protected function defineEnvironment($app)
{
$app['config']->set('auth.guards.api', [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
]);
}
protected function afterRefreshingDatabase()
{
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('name', 'username');
});
Schema::table('users', function (Blueprint $table) {
$table->tinyInteger('is_active')->default(0);
});
User::forceCreate([
'username' => 'taylorotwell',
'email' => '[email protected]',
'password' => bcrypt('password'),
'is_active' => true,
]);
}
public function testActingAsIsProperlyHandledForSessionAuth()
{
Route::get('me', function (Request $request) {
return 'Hello '.$request->user()->username;
})->middleware(['auth']);
$user = User::where('username', '=', 'taylorotwell')->first();
$this->actingAs($user)
->get('/me')
->assertSuccessful()
->assertSeeText('Hello taylorotwell');
}
public function testActingAsIsProperlyHandledForAuthViaRequest()
{
Route::get('me', function (Request $request) {
return 'Hello '.$request->user()->username;
})->middleware(['auth:api']);
Auth::viaRequest('api', function ($request) {
return $request->user();
});
$user = User::where('username', '=', 'taylorotwell')->first();
$this->actingAs($user, 'api')
->get('/me')
->assertSuccessful()
->assertSeeText('Hello taylorotwell');
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Illuminate\Tests\Integration\Foundation\Testing\Concerns;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Foundation\Auth\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\TestCase;
#[WithMigration]
class InteractsWithAuthenticationTest extends TestCase
{
use RefreshDatabase;
protected function defineEnvironment($app)
{
$app['config']->set('auth.guards.api', [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
]);
}
protected function afterRefreshingDatabase()
{
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('name', 'username');
});
Schema::table('users', function (Blueprint $table) {
$table->tinyInteger('is_active')->default(0);
});
User::forceCreate([
'username' => 'taylorotwell',
'email' => '[email protected]',
'password' => bcrypt('password'),
'is_active' => true,
]);
}
public function testActingAsIsProperlyHandledForSessionAuth()
{
Route::get('me', function (Request $request) {
return 'Hello '.$request->user()->username;
})->middleware(['auth']);
$user = User::where('username', '=', 'taylorotwell')->first();
$this->actingAs($user)
->get('/me')
->assertSuccessful()
->assertSeeText('Hello taylorotwell');
}
public function testActingAsIsProperlyHandledForAuthViaRequest()
{
Route::get('me', function (Request $request) {
return 'Hello '.$request->user()->username;
})->middleware(['auth:api']);
Auth::viaRequest('api', function ($request) {
return $request->user();
});
$user = User::where('username', '=', 'taylorotwell')->first();
$this->actingAs($user, 'api')
->get('/me')
->assertSuccessful()
->assertSeeText('Hello taylorotwell');
}
}
Function Calls
| None |
Stats
| MD5 | c89fa7932f0b17c552f112d6df1b0263 |
| Eval Count | 0 |
| Decode Time | 111 ms |