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/Admin/AddressProofTypeTest.php
<?php

namespace Tests\Unit\Admin;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use App\Models\AddressProofType;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Support\Str;

class AddressProofTypeTest extends TestCase
{
     protected $users , $clientData, $role;
    protected function setUp(): void 
    {
        parent::setUp();

        $this->role = \DB::table('roles')->where('id',1)->first();
        /*$user = factory(\App\User::class)->make();
        $this->users = $user;*/

       /* $client = factory(\App\Models\AddressProofType::class)->create();
        $this->clientData = $client;*/

    }

    public function test_admin_to_create_address_proof_type()
    {
        $userAdmin = factory(\App\User::class)->create(['role'=>$this->role->id]);
         $name = Str::random(10);
        $this->withoutMiddleware();
        $this->withoutExceptionHandling();

        $this->actingAs($userAdmin)->json('GET','/admin/address_proof_type');
        $data = [
            "address_proof_type" => $name,
        ];
        
        $response = $this->json('POST', 'api/admin/address_proof_type/store', $data, 
            [
                'Accept' => 'application/json', 
                'HTTP_Authorization' => 'Bearer' . $userAdmin->remember_token
            ])
            ->assertStatus(200);
        $response->assertOk();

        AddressProofType::where('address_proof_type', $name)->delete();
        \App\User::where('id',$userAdmin->id)->delete();

       /*  $response1 = $this->post('/api/admin/address_proof_type/store', $data);
        dd($response1->getContent()); // add this temporarily
        $response1->assertResponseStatus(200);*/

    }

    public function test_admin_to_update_address_proof_type ()
    {   
         $userAdmin = factory(\App\User::class)->create(['role'=>$this->role->id]);
        $create = factory(AddressProofType::class)->create();
        $this->withoutMiddleware();
        $this->withoutExceptionHandling();

        $this->actingAs($userAdmin)->json('GET','/admin/address_proof_type');
      

       $data = [
            'address_proof_type_id' => $create->id,
            "address_proof_type" =>"xffgdfgf ddfgfdg",
        ];
         
        $response = $this->json('POST', 'api/admin/address_proof_type/update', $data, 
            [
                'Accept' => 'application/json', 
                'HTTP_Authorization' => 'Bearer' . $userAdmin->remember_token
            ])
            ->assertStatus(200);
        $response->assertOk();
           AddressProofType::where('id', $create->id)->delete();
        \App\User::where('id',$userAdmin->id)->delete();
     
    }



    public function test_admin_to_delete_address_proof_type ()
    {
        $userAdmin = factory(\App\User::class)->create(['role'=>$this->role->id]);
        $this->withoutMiddleware();
        $this->withoutExceptionHandling();

        $this->actingAs($userAdmin)->json('GET','/admin/address_proof_type');
        // $response->assertOk();

        $create = factory(\App\Models\AddressProofType::class)->create();

       $data = [
            'id' => $create->id,
        ];
         
        $response = $this->json('POST', 'api/admin/address_proof_type/delete', $data, 
            [
                'Accept' => 'application/json', 
                'HTTP_Authorization' => 'Bearer' . $userAdmin->remember_token
            ])
            ->assertStatus(200);
           
        $response->assertOk();
        AddressProofType::where('id', $create->id)->delete();
        \App\User::where('id',$userAdmin->id)->delete();
       /* $response1 = $this->post('/api/admin/client/delete', $data);
        dd($response1->getContent()); // add this temporarily
        $response1->assertResponseStatus(200);*/
    }

    public function tearDown(): void
    {
        $maxId = \DB::table('address_proof_types')->max('id');
        \DB::statement('ALTER TABLE address_proof_types AUTO_INCREMENT=' . intval($maxId + 1) . ';');

        $maxId = \DB::table('users')->max('id');
        \DB::statement('ALTER TABLE users AUTO_INCREMENT=' . intval($maxId + 1) . ';');
        parent::tearDown();
    }
}