mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim-api.git
synced 2026-08-19 20:44:04 +00:00
3c1f2c522d
# Conflicts: # Dockerfile # app/Company.php # app/Http/Controllers/CompanyController.php # app/Http/Kernel.php # app/User.php # composer.json # composer.lock # config/app.php # package-lock.json # routes/api.php # tests/TestCase.php
39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
|
|
use App\User;
|
|
|
|
abstract class TestCase extends BaseTestCase
|
|
{
|
|
use RefreshDatabase;
|
|
use CreatesApplication;
|
|
|
|
protected function headers($user = null)
|
|
{
|
|
$token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xMjcuMC4wLjE6ODAwMFwvYXBpXC9sb2dpbiIsImlhdCI6MTUyNjQ1ODExMiwiZXhwIjoxNTI3NjY3NzEyLCJuYmYiOjE1MjY0NTgxMTIsImp0aSI6InVnOFJnellnbzlVNWxWQ1kiLCJzdWIiOjUsInBydiI6Ijg3ZTBhZjFlZjlmZDE1ODEyZmRlYzk3MTUzYTE0ZTBiMDQ3NTQ2YWEifQ.NosAWtXlIPzGVYYz46CoPhseo0WQPQZpuR1t9mCwvX0";
|
|
$headers = ['HTTP_Authorization' => 'Bearer '.$token];
|
|
|
|
return $headers;
|
|
}
|
|
protected $user;
|
|
|
|
public function actingAs(UserContract $user, $driver = null)
|
|
{
|
|
$this->user = $user;
|
|
return $this;
|
|
}
|
|
|
|
public function call($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
|
|
{
|
|
if ($this->user) {
|
|
$server['HTTP_AUTHORIZATION'] = 'Bearer ' . \JWTAuth::fromUser($this->user);
|
|
}
|
|
$server['HTTP_ACCEPT'] = 'application/json';
|
|
return parent::call($method, $uri, $parameters, $cookies, $files, $server, $content);
|
|
}
|
|
}
|