File manager - Edit - /var/www/html/portal/tests/Feature/AuthFlowsTest.php
Back
<?php namespace Tests\Feature; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; use App\Models\User; use App\Http\Services\Accounts\ServicoDeSenha; use App\Http\Services\Accounts\ServicoDeContaPublica; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Mail; use App\Mail\RecuperacaoSenhaMail; class AuthFlowsTest extends TestCase { public function test_iniciar_solicitacao_cria_registro() { $servico = new ServicoDeContaPublica(); $ok = $servico->iniciarSolicitacao('12345678909', 'teste@example.com'); $this->assertTrue((bool)$ok); } public function test_enviar_token_recuperacao_para_usuario_inexistente_falha() { $servico = new ServicoDeSenha(); $ok = $servico->enviarTokenRecuperacao('naoexiste@example.com'); $this->assertEquals('not_found', $ok); } public function test_recuperacao_de_senha_com_cpf_82929750120() { Mail::fake(); $user = User::where('cpf','82929750120')->first(); if (!$user) { $user = new User(); $user->firstName = 'Teste'; $user->lastName = 'Recuperacao'; $user->cpf = '82929750120'; $user->email = 'teste.recuperacao@angra.rj.gov.br'; $user->structure_id = env('STRUCTURE_DEFAULT_ID'); $user->phoneNumber = '21999999999'; $user->password = 'secret'; $user->status = 'ATIVADO'; $user->isPasswordDefault = 0; $user->save(); } else if (empty($user->email)) { $user->email = 'teste.recuperacao@angra.rj.gov.br'; $user->save(); } $servico = new ServicoDeSenha(); $result = $servico->enviarTokenRecuperacao('82929750120'); $this->assertContains($result, ['ok','cooldown']); $exists = DB::table('password_reset_tokens')->where('email', $user->email)->exists(); $this->assertTrue($exists); Mail::assertSent(RecuperacaoSenhaMail::class, function($m) use ($user){ return $m->user->id === $user->id; }); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings