File manager - Edit - /var/www/html/gop/api/tests/Feature/ObraTest.php
Back
<?php namespace Tests\Feature; use App\Models\Obra; use Illuminate\Http\JsonResponse; use Illuminate\Http\UploadedFile; use Tests\BaseTest; class ObraTest extends BaseTest { public function test_index() { Obra::factory(2)->create([ 'organization_id' => '9b0a47f8-4d96-4e25-beaa-34ca2dda6447', ]); Obra::factory(2)->create([ 'organization_id' => 'teste2', ]); Obra::factory(2)->create(); $this->authRequest( 'get', route('obras.index'), ); } public function test_store() { $obraArray = Obra::factory()->make()->toArray(); $obraArray['valor_inicial'] = (float) $obraArray['valor_inicial']; $response = $this->authRequest( 'post', route('obras.store'), JsonResponse::HTTP_CREATED, $obraArray, ); $response->assertSee($obraArray['numero']); } public function test_geraPdf() { $obra = Obra::factory()->create(); $response = $this->authRequest( 'get', route('obras.geraPdf', $obra->id), ); $path = $response->json(); $path = str_replace('\\', '/', $path); $storagePath = storage_path('app/'.str($path)->after('storage/')); $this->removeTestFiles($storagePath); } public function test_show() { $obra = Obra::factory()->create(); $obra->setPrivateFields([ 'nome', 'contrato', 'modalidade', 'processo', 'numero', 'ano', 'valor_inicial', 'valor_ajustado', 'servico', 'empresa_id', 'ordenador_id', 'endereco_id', 'responsavel_fiscalizacao_id', 'responsavel_firma_id', 'responsavel_tecnico_id', 'data', 'prazo_inicial', 'prazo_ajustado', ]); $this->simpleRequest( 'get', route('obra.show', $obra->id), ); } public function test_update() { $obra = Obra::factory()->create(); $obraArray = Obra::factory()->make()->toArray(); $obraArray['valor_inicial'] = (float) $obraArray['valor_inicial']; $obraArray['motivo'] = 'Se aposentou.'; $this->authRequest( 'put', route('obras.update', $obra->id), JsonResponse::HTTP_OK, $obraArray, ); } public function test_destroy() { $obra = Obra::factory()->create(); $this->authRequest( 'delete', route('obras.destroy', $obra->id), JsonResponse::HTTP_NO_CONTENT, ); } public function test_setPrivateFields() { $obra = Obra::factory()->create(); $request = [ 'fields' => [ 'id', ], ]; $this->authRequest( 'post', route('obras.setPrivateFields', $obra->id), JsonResponse::HTTP_OK, $request, ); $this->authRequest( 'get', route('obras.show', $obra->id), ); } public function test_showPrivateFields() { $obra = Obra::factory()->create(); $request = [ 'fields' => [ 'id', ], ]; $this->authRequest( 'post', route('obras.setPrivateFields', $obra->id), JsonResponse::HTTP_OK, $request, ); $this->authRequest( 'get', route('obras.setPrivateFields', $obra->id), ); } public function test_storeImage_and_showImage() { $modelo = Obra::factory()->create(); $image = new UploadedFile( storage_path('test/assinatura.png'), 'assinatura.png', 'image/png', null, true ); $request = [ 'image' => $image, ]; $response = $this->authRequest( 'post', route('obra.storeImage', $modelo->id), JsonResponse::HTTP_CREATED, $request, ); $this->authRequest( 'get', route('obra.showModelImages', $modelo->id), JsonResponse::HTTP_OK, $request, ); $this->removeTestFiles($response->json('path')); } public function test_storeFile_and_showFile() { $modelo = Obra::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('obra.storeFile', $modelo->id), JsonResponse::HTTP_CREATED, $request, ); $this->authRequest( 'get', route('obra.showModelFiles', $modelo->id), JsonResponse::HTTP_OK, $request, ); $this->removeTestFiles($response->json('path')); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings