Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ Though the experience is not that refined...
# Start the stack in the background
docker compose up -d

# View locally sent email, including account verification links
# http://localhost:8025/

# Stop the stack and delete all volumes
docker compose down --volumes
```

The Compose setup sends email to the local MailHog inbox instead of an external
mail provider.

### Migrations

Run everything in one go:
Expand Down
12 changes: 11 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ services:
restart: always
depends_on:
- sql
- mailhog
links:
- sql
- redis
environment:
- CONTAINER_ROLE=app
CONTAINER_ROLE: app
MAIL_MAILER: smtp
MAIL_HOST: mailhog
MAIL_PORT: 1025
MAIL_ENCRYPTION: ""
sql:
image: "${DOCKER_DATABASE_IMAGE_NAME}"
environment:
Expand All @@ -41,6 +46,11 @@ services:
restart: always
expose:
- 6379
mailhog:
image: mailhog/mailhog:v1.0.1
restart: always
ports:
- 127.0.0.1:8025:8025

volumes:
sql-data:
Expand Down
17 changes: 10 additions & 7 deletions tests/Routes/Complaint/SendMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
use App\Rules\ReCaptchaValidation;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Notifications\AnonymousNotifiable;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Notification;
use Symfony\Component\Mailer\Exception\TransportException;
use Symfony\Component\Mailer\Transport\TransportInterface;
use Tests\TestCase;

class SendMessageTest extends TestCase {
Expand Down Expand Up @@ -66,15 +68,16 @@ private function assertComplaintNotRecorded() {
public function testRecordOnMailFail() {
$this->mockReCaptchaValidation();

$data = $this->postDataTemplateFilled;
$transport = $this->createMock(TransportInterface::class);
$transport->expects($this->once())
->method('send')
->willThrowException(new TransportException('Simulated mail delivery failure'));
Mail::mailer()->setSymfonyTransport($transport);

try {
$response = $this->json('POST', $this->route, $data);
} catch (TransportException $e) {
return;
}
$data = $this->postDataTemplateFilled;

$this->assertNotEquals($response->status(), 200);
$response = $this->json('POST', $this->route, $data);
$response->assertStatus(500);

$this->assertComplaintRecorded();
$this->assertComplaintNotMarkedAsDispatched();
Expand Down
Loading