* chore(deps): bump stevebauman/location from 3.0.1 to 5.0.0 Bumps [stevebauman/location](https://github.com/stevebauman/location) from 3.0.1 to 5.0.0. - [Release notes](https://github.com/stevebauman/location/releases) - [Commits](https://github.com/stevebauman/location/compare/v3.0.1...v5.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
51 lines
1.0 KiB
PHP
51 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Helpers;
|
|
|
|
use Tests\TestCase;
|
|
use App\Helpers\RequestHelper;
|
|
use Illuminate\Support\Facades\Request;
|
|
|
|
class RequestHelperTest extends TestCase
|
|
{
|
|
public function test_get_cf_ip()
|
|
{
|
|
Request::instance()->headers->set('Cf-Connecting-Ip', '1.2.3.4');
|
|
|
|
$this->assertEquals(
|
|
'1.2.3.4',
|
|
RequestHelper::ip()
|
|
);
|
|
}
|
|
|
|
public function test_get_server_ip()
|
|
{
|
|
Request::instance()->server->set('REMOTE_ADDR', '1.2.3.4');
|
|
|
|
$this->assertEquals(
|
|
'1.2.3.4',
|
|
RequestHelper::ip()
|
|
);
|
|
}
|
|
|
|
public function test_get_country_from_cf()
|
|
{
|
|
Request::instance()->headers->set('Cf-Ipcountry', 'XX');
|
|
|
|
$this->assertEquals(
|
|
'XX',
|
|
RequestHelper::country('1.2.3.4')
|
|
);
|
|
}
|
|
|
|
public function test_get_country_from_ip()
|
|
{
|
|
Request::instance()->server->set('REMOTE_ADDR', '123.45.67.89');
|
|
|
|
$this->assertEquals(
|
|
'KR',
|
|
RequestHelper::country(null)
|
|
);
|
|
}
|
|
}
|