Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

1.8 KB
Raw Blame
<?php

namespace Tests\Unit\Mail\Account;

use Closure;
use HiEvents\Mail\Account\AdminAccessGrantedMail;
use ReflectionClass;
use Tests\TestCase;

class AdminAccessGrantedMailTest extends TestCase
{
    public function test_an_active_admin_is_described_as_having_access(): void
    {
        $html = (new AdminAccessGrantedMail(
            newAdminEmail: '[email protected]',
            grantedByEmail: '[email protected]',
        ))->render();

        $this->assertStringContainsString('[email protected] now has admin access', $html);
        $this->assertStringContainsString('remove their access', $html);
        $this->assertStringNotContainsString('was invited', $html);
    }

    public function test_a_pending_invitation_is_described_as_an_invitation(): void
    {
        $html = (new AdminAccessGrantedMail(
            newAdminEmail: '[email protected]',
            grantedByEmail: '[email protected]',
            isInvitation: true,
        ))->render();

        $this->assertStringContainsString('[email protected] was invited as an admin', $html);
        $this->assertStringContainsString('They get access once they accept', $html);
        $this->assertStringContainsString('remove the invitation', $html);
        $this->assertStringNotContainsString('now has admin access', $html);
    }

    public function test_a_mail_queued_by_a_previous_release_renders_the_access_wording(): void
    {
        $mail = (new ReflectionClass(AdminAccessGrantedMail::class))->newInstanceWithoutConstructor();
        Closure::bind(function (): void {
            $this->newAdminEmail = '[email protected]';
            $this->grantedByEmail = null;
        }, $mail, AdminAccessGrantedMail::class)();

        $this->assertFalse($mail->content()->with['isInvitation']);
    }
}