81 lines
2.6 KiB
PHP
81 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature\PublicSite;
|
|
|
|
use App\Mail\PartnerInquiry;
|
|
use App\Models\SiteSetting;
|
|
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use Tests\TestCase;
|
|
|
|
class PartnerInquiryTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->withoutMiddleware([ThrottleRequests::class, PreventRequestForgery::class]);
|
|
}
|
|
|
|
/** @return array<string, string> */
|
|
private function validPayload(array $overrides = []): array
|
|
{
|
|
return array_merge([
|
|
'nome' => 'Ana Costa',
|
|
'empresa' => 'Flores da Ana',
|
|
'email' => 'ana@example.com',
|
|
'atuacao' => 'Florista',
|
|
'area_atendimento' => 'São Paulo capital',
|
|
'mensagem' => 'Gostaria de apresentar nosso portfólio para futuras parcerias.',
|
|
'portfolio_redes' => 'https://instagram.com/floresdaana',
|
|
'telefone' => '(11) 98888-7777',
|
|
'website' => '',
|
|
], $overrides);
|
|
}
|
|
|
|
public function test_contact_page_is_a_partner_journey_not_the_event_briefing(): void
|
|
{
|
|
SiteSetting::instance();
|
|
|
|
$this->get(route('contact'))
|
|
->assertOk()
|
|
->assertSee('Fornecedores e parcerias')
|
|
->assertSee('name="atuacao"', false)
|
|
->assertSee('name="area_atendimento"', false)
|
|
->assertSee('name="website"', false)
|
|
->assertDontSee('name="tipo_evento"', false)
|
|
->assertSee(route('privacy'), false);
|
|
}
|
|
|
|
public function test_valid_partner_inquiry_sends_only_the_dedicated_internal_email(): void
|
|
{
|
|
$settings = SiteSetting::instance();
|
|
Mail::fake();
|
|
|
|
$this->post(route('contact.store'), $this->validPayload())
|
|
->assertRedirect(route('contact'))
|
|
->assertSessionHas('status', 'partner-inquiry-sent');
|
|
|
|
Mail::assertQueued(PartnerInquiry::class, fn (PartnerInquiry $mail): bool => $mail->hasTo($settings->email));
|
|
Mail::assertQueued(PartnerInquiry::class, 1);
|
|
}
|
|
|
|
public function test_partner_honeypot_reports_success_without_sending_mail(): void
|
|
{
|
|
SiteSetting::instance();
|
|
Mail::fake();
|
|
|
|
$this->post(route('contact.store'), $this->validPayload(['website' => 'https://spam.invalid']))
|
|
->assertRedirect(route('contact'))
|
|
->assertSessionHas('status', 'partner-inquiry-sent');
|
|
|
|
Mail::assertNothingSent();
|
|
}
|
|
}
|