catch project exceptions

This commit is contained in:
= 2021-03-20 11:16:29 +11:00
parent a9233ba62f
commit 7173ba2931
3 changed files with 24 additions and 1 deletions

View File

@ -54,7 +54,7 @@ class QueryLogging
nlog($request->method().' - '.$request->url().": $count queries - ".$time);
// if($count > 50)
// Log::nlog($queries);
//nlog($queries);
}
}

View File

@ -37,6 +37,7 @@ class Project extends BaseModel
'custom_value4',
'assigned_user_id',
'color',
'number',
];
public function getEntityType()

View File

@ -16,6 +16,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Session;
use Tests\MockAccountData;
use Tests\TestCase;
use Illuminate\Validation\ValidationException;
/**
* @test
@ -56,6 +57,7 @@ class ProjectApiTest extends TestCase
$data = [
'name' => $this->faker->firstName,
'client_id' => $this->client->hashed_id,
'number' => 'duplicate',
];
$response = $this->withHeaders([
@ -64,6 +66,26 @@ class ProjectApiTest extends TestCase
])->post('/api/v1/projects', $data);
$response->assertStatus(200);
$arr = $response->json();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->put('/api/v1/projects/'.$arr['data']['id'], $data)->assertStatus(200);
try{
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/projects', $data);
}
catch(ValidationException $e){
$response->assertStatus(302);
}
}
public function testProjectPut()