<?php namespace Laravel\Sanctum\Tests; use Illuminate\Http\Request; use Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful; use Orchestra\Testbench\TestCase; class DefaultConfigContainsAppUrlTest extends TestCase { protected function getEnvironmentSetUp($app) { putenv('APP_URL=https://www.example.com'); $app['config']->set('app.url', 'https://www.example.com'); $config = require __DIR__.'/../config/sanctum.php'; $app['config']->set('sanctum.stateful', $config['stateful']); } public function test_default_config_contains_app_url() { $config = require __DIR__.'/../config/sanctum.php'; $app_host = parse_url(env('APP_URL'), PHP_URL_HOST); $this->assertContains($app_host, $config['stateful']); } public function test_app_url_is_not_parsed_when_missing_from_env() { putenv('APP_URL'); config(['app.url' => null]); $config = require __DIR__.'/../config/sanctum.php'; $this->assertNull(env('APP_URL')); $this->assertNotContains('', $config['stateful']); putenv('APP_URL=https://www.example.com'); config(['app.url' => 'https://www.example.com']); } public function test_request_from_app_url_is_stateful_with_default_config() { $request = Request::create('/'); $request->headers->set('referer', config('app.url')); $this->assertTrue(EnsureFrontendRequestsAreStateful::fromFrontend($request)); } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
ActingAsTest.php | File | 4.66 KB | 0644 |
|
CheckAbilitiesTest.php | File | 2.47 KB | 0644 |
|
CheckForAnyAbilityTest.php | File | 2.56 KB | 0644 |
|
CheckForAnyScopeTest.php | File | 2.54 KB | 0644 |
|
CheckScopesTest.php | File | 2.44 KB | 0644 |
|
DefaultConfigContainsAppUrlTest.php | File | 1.53 KB | 0644 |
|
EnsureFrontendRequestsAreStatefulTest.php | File | 2.65 KB | 0644 |
|
GuardTest.php | File | 18.88 KB | 0644 |
|
HasApiTokensTest.php | File | 1.52 KB | 0644 |
|
PersonalAccessTokenTest.php | File | 766 B | 0644 |
|
PruneExpiredTest.php | File | 5.55 KB | 0644 |
|
TransientTokenTest.php | File | 482 B | 0644 |
|