MOON
Server: Apache
System: Linux e2e-78-16.ssdcloudindia.net 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
User: imensosw (1005)
PHP: 8.0.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/imensosw/.trash/tests.1/Unit/Translator/UserProfileTest.php
<?php

namespace Tests\Unit\Translator;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use App\User;
class UserProfileTest extends TestCase
{
    protected $users, $clientData, $subject, $expertise;
    protected function setUp(): void 
    {
        parent::setUp();
        // $this->expertise = Expertise::inRandomOrder()->first();

        // $this->subject = Subject::inRandomOrder()->first();

        // $this->translator_status = TranslatorStatus::where('id',2)->first();

    }

    public function test_to_get_user_profile()
    {
        $this->withoutMiddleware();
        $this->withoutExceptionHandling();
        $response = $this->json('GET','/getUserProfileInfo');
        $response->assertOk();

    }

    public function test_to_update_user_profile()
    {
        $user = factory(User::class)->create();
        $profile =  factory(\App\Models\Profile::class)->create(['user_id'=>$user->id]);
        $this->withoutMiddleware();
        $this->withoutExceptionHandling();

        $this->actingAs($user)->json('GET','/getUserProfileInfo');
        $data = [
            "fname" => "TEst",
            "lname" => "TEst",
            "mobile_country_code_id" => 2,
            "mobile_no" => 1234567890,
            "whatup_country_code_id" => 2,
            "whatup_no" => 1234567890,
            "avatar" => null,
            "bio_data" => "Test Test Test Test Test",
            "gender_id" => 1,
            "nationality_country_id" => 1,
            "residence_country_id" => 1,
        ];
        
        $response = $this->json('POST', 'api/updateProfile', $data, 
            [
                'Accept' => 'application/json', 
                'HTTP_Authorization' => 'Bearer' . $user->remember_token
            ])
            ->assertStatus(200);
        $response->assertOk();
        \App\Models\Profile::where('user_id', $user->id)->delete();
        \App\User::where('id', $user->id)->delete();
    }

    public function tearDown(): void
    {
        $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();
    }

}