File manager - Edit - /var/www/html/gop/api/tests/Feature/EmpenhoTest.php
Back
<?php namespace Tests\Feature; use App\Models\Arquivo; use App\Models\Empenho; use App\Models\Image; use Illuminate\Http\JsonResponse; use Illuminate\Http\UploadedFile; use Tests\BaseTest; class EmpenhoTest extends BaseTest { public function test_index() { Empenho::factory(10)->create(); $this->authRequest( 'get', route('empenho.index'), ); } public function test_store() { $empenhoArray = Empenho::factory()->make()->toArray(); $empenhoArray['valor'] = (float) $empenhoArray['valor']; $empenhoArray['numero'] = (string) $empenhoArray['numero']; $response = $this->authRequest( 'post', route('empenho.store'), JsonResponse::HTTP_CREATED, $empenhoArray, ); $response->assertSee($empenhoArray['numero']); } public function test_show() { $empenho = Empenho::factory()->create(); $arquivos = Arquivo::factory(3)->create([ 'arquivable_id' => $empenho->id, 'arquivable_type' => Empenho::class, ]); $images = Image::factory(3)->create([ 'imageable_id' => $empenho->id, 'imageable_type' => Empenho::class, ]); $this->authRequest( 'get', route('empenho.show', $empenho->id), ); foreach ($arquivos as $arquivo) { $this->removeTestFiles($arquivo->path); } foreach ($images as $image) { $this->removeTestFiles($image->path); } } public function test_update() { $empenho = Empenho::factory()->create(); $empenhoArray = Empenho::factory()->make([ 'obra_id' => $empenho->obra_id, ])->toArray(); $empenhoArray['valor'] = (float) $empenho['valor'] * 2; $empenhoArray['numero'] = (string) $empenhoArray['numero']; $this->authRequest( 'put', route('empenho.update', $empenho->id), JsonResponse::HTTP_OK, $empenhoArray, ); } public function test_destroy() { $empenho = Empenho::factory()->create(); $this->authRequest( 'delete', route('empenho.destroy', $empenho->id), JsonResponse::HTTP_NO_CONTENT, ); } public function test_storeImage_and_showImage() { $modelo = Empenho::factory()->create(); $image = new UploadedFile( storage_path('test/assinatura.png'), 'assinatura.png', 'image/png', null, true ); $request = [ 'image' => $image, ]; $response = $this->authRequest( 'post', route('empenho.storeImage', $modelo->id), JsonResponse::HTTP_CREATED, $request, ); $this->authRequest( 'get', route('empenho.showModelImages', $modelo->id), JsonResponse::HTTP_OK, $request, ); $this->removeTestFiles($response->json('path')); } public function test_storeFile_and_showFile() { $modelo = Empenho::factory()->create(); $file = new UploadedFile( storage_path('test/pdf-test.pdf'), 'pdf-test.pdf', 'file/pdf', null, true ); $request = [ 'arquivo' => $file, ]; $response = $this->authRequest( 'post', route('empenho.storeFile', $modelo->id), JsonResponse::HTTP_CREATED, $request, ); $this->authRequest( 'get', route('empenho.showModelFiles', $modelo->id), JsonResponse::HTTP_OK, $request, ); $this->removeTestFiles($response->json('path')); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings