File: /home/imensosw/.trash/tests.1/Unit/Translator/UserSoftwareToolTest.php
<?php
namespace Tests\Unit\Translator;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Support\Str;
use App\Models\UserSoftwareTool;
use App\Models\SoftwareTool;
use App\Models\Software;
class UserSoftwareToolTest extends TestCase
{
protected $users, $clientData;
protected function setUp(): void
{
parent::setUp();
}
public function test_to_get_user_software_tool()
{
$this->withoutMiddleware();
$this->withoutExceptionHandling();
$response = $this->json('GET','/getUserSoftwareTools');
$response->assertOk();
}
public function test_to_update_user_software_tool()
{
$user = factory(\App\User::class)->create();
$profile = factory(\App\Models\Profile::class)->create(['user_id'=>$user->id]);
$this->withoutMiddleware();
$this->withoutExceptionHandling();
$this->actingAs($user)->json('GET','/getUserSoftwareTools');
$data = [
"user_id" => $user->id,
// "subject_id" => $this->subject->id,
// "expertise_id" => $this->expertise->id,
];
$response = $this->json('POST', 'api/updateUserSoftwareTools', $data,
[
'Accept' => 'application/json',
'HTTP_Authorization' => 'Bearer' . $user->remember_token
])
->assertStatus(200);
$response->assertOk();
\App\Models\UserSoftwareTool::where('user_id', $user->id)->delete();
\App\Models\Profile::where('user_id', $user->id)->delete();
\App\User::where('id', $user->id)->delete();
}
public function tearDown(): void
{
$maxId = \DB::table('user_software_tools')->max('id');
\DB::statement('ALTER TABLE user_software_tools AUTO_INCREMENT=' . intval($maxId + 1) . ';');
$maxId = \DB::table('profiles')->max('id');
\DB::statement('ALTER TABLE profiles AUTO_INCREMENT=' . intval($maxId + 1) . ';');
$maxId = \DB::table('users')->max('id');
\DB::statement('ALTER TABLE users AUTO_INCREMENT=' . intval($maxId + 1) . ';');
parent::tearDown();
}
}