-
Notifications
You must be signed in to change notification settings - Fork 318
Expand file tree
/
Copy pathDefaultConfigContainsAppUrlTest.php
More file actions
57 lines (40 loc) · 1.58 KB
/
DefaultConfigContainsAppUrlTest.php
File metadata and controls
57 lines (40 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace Laravel\Sanctum\Tests\Feature;
use Illuminate\Http\Request;
use Laravel\Sanctum\Http\Middleware\FrontendRequestChecker;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\TestCase;
use function Orchestra\Testbench\package_path;
class DefaultConfigContainsAppUrlTest extends TestCase
{
use WithWorkbench;
protected function defineEnvironment($app)
{
putenv('APP_URL=https://www.example.com');
$app['config']->set('app.url', 'https://www.example.com');
$config = require package_path('config/sanctum.php');
$app['config']->set('sanctum.stateful', $config['stateful']);
}
public function test_default_config_contains_app_url()
{
$config = require package_path('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 package_path('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(FrontendRequestChecker::isFromFrontend($request));
}
}