|
| 1 | +<?php namespace Tests\unit; |
| 2 | + |
| 3 | +/** |
| 4 | + * Copyright 2026 OpenStack Foundation |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * Unless required by applicable law or agreed to in writing, software |
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | + * See the License for the specific language governing permissions and |
| 13 | + * limitations under the License. |
| 14 | + **/ |
| 15 | + |
| 16 | +use App\Mail\UserEmailVerificationRequest; |
| 17 | +use Auth\User; |
| 18 | +use Illuminate\Support\Facades\Config; |
| 19 | +use Illuminate\Support\Facades\Mail; |
| 20 | +use Illuminate\Support\Facades\Queue; |
| 21 | +use Tests\BrowserKitTestCase; |
| 22 | + |
| 23 | +class EmailVerificationViewTest extends BrowserKitTestCase |
| 24 | +{ |
| 25 | + protected function prepareForTests(): void |
| 26 | + { |
| 27 | + $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.1'; |
| 28 | + Queue::fake(); |
| 29 | + Mail::fake(); |
| 30 | + } |
| 31 | + |
| 32 | + private function makeUser(string $email): User |
| 33 | + { |
| 34 | + $user = $this->createMock(User::class); |
| 35 | + $user->method('getEmail')->willReturn($email); |
| 36 | + $user->method('getFullName')->willReturn('Preview User'); |
| 37 | + return $user; |
| 38 | + } |
| 39 | + |
| 40 | + public function testFnVerificationEmailRendersAndSends(): void |
| 41 | + { |
| 42 | + Config::set('app.tenant_name', 'FNTECH'); |
| 43 | + |
| 44 | + $email = 'preview+fntech@example.com'; |
| 45 | + $verificationLink = 'https://id.fntech.com/verify/abc123deadbeef'; |
| 46 | + |
| 47 | + $mailable = new UserEmailVerificationRequest($this->makeUser($email), $verificationLink); |
| 48 | + |
| 49 | + $mailable->assertHasSubject( |
| 50 | + sprintf('[%s] Email verification required', Config::get('app.app_name')) |
| 51 | + ); |
| 52 | + $mailable->assertTo($email); |
| 53 | + |
| 54 | + $html = $mailable->render(); |
| 55 | + |
| 56 | + $this->assertStringContainsString('Confirm your email.', $html); |
| 57 | + $this->assertStringContainsString($email, $html); |
| 58 | + $this->assertStringContainsString($verificationLink, $html); |
| 59 | + $this->assertStringContainsString('Verify email', $html); |
| 60 | + $this->assertStringContainsString('paste this link', $html); |
| 61 | + // _fn footer shows tenant support team, not an arbitrary help email |
| 62 | + $this->assertStringContainsString('Questions?', $html); |
| 63 | + // _fn view has no profile-edit section |
| 64 | + $this->assertStringNotContainsString('edit your profile', $html); |
| 65 | + } |
| 66 | +} |
0 commit comments