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

namespace Tests\Unit\Admin;

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


class PhotoProofTypeTest 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\PhotoProofType::class)->create();
        $this->clientData = $client;*/

    }

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

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

        PhotoProofType::where('photo_proof_type', $name)->delete();
        \App\User::where('id',$userAdmin->id)->delete();
       /*  $response1 = $this->post('/api/admin/photo_proof_type/store', $data);
        dd($response1->getContent()); // add this temporarily
        $response1->assertResponseStatus(200);*/

    }

    public function test_admin_to_update_photo_proof_type ()
    {

        $userAdmin = factory(\App\User::class)->create(['role'=>$this->role->id]);
        $create = factory(\App\Models\PhotoProofType::class)->create();
        $this->withoutMiddleware();
        $this->withoutExceptionHandling();

        $this->actingAs($userAdmin)->json('GET','/admin/photo_proof_type');
        // $response->assertOk();
      /*  $this->assertDatabaseHas('clients', [
           'id' =>$create->id,
        ]);*/

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



    public function test_admin_to_delete_photo_proof_type ()
    {

        $this->withoutMiddleware();
        $this->withoutExceptionHandling();
        $userAdmin = factory(\App\User::class)->create(['role'=>$this->role->id]);
        $this->actingAs($userAdmin)->json('GET','/admin/photo_proof_type');
        // $response->assertOk();

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

       $data = [
            'id' => $create->id,
        ];
         
        $response = $this->json('POST', 'api/admin/photo_proof_type/delete', $data, 
            [
                'Accept' => 'application/json', 
                'HTTP_Authorization' => 'Bearer' . $userAdmin->remember_token
            ])
            ->assertStatus(200);
           
        $response->assertOk();
        PhotoProofType::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('photo_proof_types')->max('id');
        \DB::statement('ALTER TABLE photo_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();
    }
}