mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-11-27 05:39:55 +08:00
Tweak TestCase
This commit is contained in:
parent
9402f5f83e
commit
e48bd1f9c6
@ -299,21 +299,13 @@ if (! function_exists('get_client_ip')) {
|
||||
*/
|
||||
function get_client_ip(): string
|
||||
{
|
||||
$request = request();
|
||||
if (option('ip_get_method') == '0') {
|
||||
// Use `HTTP_X_FORWARDED_FOR` if available first
|
||||
$ip = Arr::get(
|
||||
$_SERVER,
|
||||
'HTTP_X_FORWARDED_FOR',
|
||||
// Fallback to `HTTP_CLIENT_IP`
|
||||
Arr::get(
|
||||
$_SERVER,
|
||||
'HTTP_CLIENT_IP',
|
||||
// Fallback to `REMOTE_ADDR`
|
||||
Arr::get($_SERVER, 'REMOTE_ADDR')
|
||||
)
|
||||
);
|
||||
$ip = $request->server('HTTP_X_FORWARDED_FOR')
|
||||
?? $request->server('HTTP_CLIENT_IP')
|
||||
?? $request->server('REMOTE_ADDR');
|
||||
} else {
|
||||
$ip = Arr::get($_SERVER, 'REMOTE_ADDR');
|
||||
$ip = $request->server('REMOTE_ADDR');
|
||||
}
|
||||
|
||||
return $ip;
|
||||
@ -350,15 +342,16 @@ if (! function_exists('is_request_secure')) {
|
||||
*/
|
||||
function is_request_secure(): bool
|
||||
{
|
||||
if (Arr::get($_SERVER, 'HTTPS') == 'on') {
|
||||
$request = request();
|
||||
if ($request->server('HTTPS') == 'on') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Arr::get($_SERVER, 'HTTP_X_FORWARDED_PROTO') == 'https') {
|
||||
if ($request->server('HTTP_X_FORWARDED_PROTO') == 'https') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Arr::get($_SERVER, 'HTTP_X_FORWARDED_SSL') == 'on') {
|
||||
if ($request->server('HTTP_X_FORWARDED_SSL') == 'on') {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,6 @@ class BrowserKitTestCase extends TestCase
|
||||
|
||||
Artisan::call('migrate:refresh');
|
||||
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
@ -49,12 +47,4 @@ class BrowserKitTestCase extends TestCase
|
||||
|
||||
return $this->actingAs($role);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->beforeApplicationDestroyed(function () {
|
||||
DB::disconnect();
|
||||
});
|
||||
parent::tearDown();
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +27,6 @@ class TestCase extends \Illuminate\Foundation\Testing\TestCase
|
||||
|
||||
Artisan::call('migrate:refresh');
|
||||
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
@ -48,12 +46,4 @@ class TestCase extends \Illuminate\Foundation\Testing\TestCase
|
||||
|
||||
return $this->actingAs($role);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->beforeApplicationDestroyed(function () {
|
||||
DB::disconnect();
|
||||
});
|
||||
parent::tearDown();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user