File manager - Edit - /var/www/html/gop/api/tests/Feature/TermoTest.php
Back
<?php namespace Tests\Feature; use App\Enums\Termo as TermoEnum; use App\Models\Termo; use Illuminate\Http\JsonResponse; use Tests\BaseTest; class TermoTest extends BaseTest { public function test_index() { Termo::factory(10)->create(); $this->authRequest( 'get', route('termo.index'), ); } public function test_store() { $numero = fake()->randomNumber(); $ano = fake()->year; Termo::factory()->create([ 'numero' => $numero, 'tipo' => TermoEnum::TRD, 'ano' => $ano, ]); $termoArray = Termo::factory()->state([ 'numero' => $numero, 'tipo' => TermoEnum::TRP, 'ano' => $ano, ])->make()->toArray(); $termoArray['valor'] = (float) $termoArray['valor']; $response = $this->authRequest( 'post', route('termo.store'), JsonResponse::HTTP_CREATED, $termoArray, ); $response->assertSee($termoArray['numero']); } public function test_geraPdfTrd() { $termo = Termo::factory()->create(['tipo' => TermoEnum::TRD]); $response = $this->authRequest( 'get', route('termo.geraPdf', $termo->id), ); $path = $response->json(); $path = str_replace('\\', '/', $path); $storagePath = storage_path('app/'.str($path)->after('storage/')); $this->removeTestFiles($storagePath); } public function test_geraPdfTrp() { $termo = Termo::factory()->create(['tipo' => TermoEnum::TRP]); $response = $this->authRequest( 'get', route('termo.geraPdf', $termo->id), ); $path = $response->json(); $path = str_replace('\\', '/', $path); $storagePath = storage_path('app/'.str($path)->after('storage/')); $this->removeTestFiles($storagePath); } public function test_show() { $termo = Termo::factory()->create(); $this->authRequest( 'get', route('termo.show', $termo->id), ); } public function test_getNewNumber() { Termo::factory(5)->create([ 'tipo' => TermoEnum::TRD, 'ano' => date('Y'), ]); $this->authRequest( 'get', route('termo.getNewNumber', 'TRD'), ); } public function test_update() { $termo = Termo::factory()->create(); $termoArray = Termo::factory()->make()->toArray(); $termoArray['valor'] = (float) $termoArray['valor']; $this->authRequest( 'put', route('termo.update', $termo->id), JsonResponse::HTTP_OK, $termoArray, ); } public function test_destroy() { $termo = Termo::factory()->create(); $this->authRequest( 'delete', route('termo.destroy', $termo->id), JsonResponse::HTTP_NO_CONTENT, ); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings