Laravel Dusk Fakes
Support this package!
Laravel Splade
Did you hear about Laravel Splade?
It's the magic of Inertia.js with the simplicity of Blade. Splade provides a super easy way to build Single Page Applications using Blade templates. Besides that magic SPA-feeling, it comes with more than ten components to sparkle your app and make it interactive, all without ever leaving Blade.
Installation
You can install the package via composer:
composer require protonemedia/laravel-dusk-fakes --dev
Persist Mails
Make sure you've set the DUSK_FAKE_MAILS
environment variable to true
in the Dusk environment.
Finally, add the PersistentMails
trait to your test. You don't have to manually call the fake()
method on the Mail
facade.
<?php
namespace Tests\Browser\Auth;
use App\Mail\OrderConfirmed;
use App\Models\Order;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\Mail;
use Laravel\Dusk\Browser;
use ProtoneMedia\LaravelDuskFakes\Mails\PersistentMails;
use Tests\DuskTestCase;
class OrderConfirmTest extends DuskTestCase
{
use DatabaseMigrations;
use PersistentMails;
public function test_send_order_confirmed_mailable_to_user()
{
$this->browse(function (Browser $browser) {
$order = Order::factory()->create();
$browser->visit('/order/'.$order->id)
->press('Confirm')
->waitForText('We have emailed your order confirmation!');
Mail::assertSent(OrderConfirmed::class, function ($mail) use ($user) {
return $mail->hasTo($user->email);
});
});
}
}
Persist Notifications
Make sure you've set the DUSK_FAKE_NOTIFICATIONS
environment variable to true
in the Dusk environment.
Finally, add the PersistentNotifications
trait to your test. You don't have to manually call the fake()
method on the Notification
facade.
<?php
namespace Tests\Browser\Auth;
use App\Models\User;
use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\Notification;
use Laravel\Dusk\Browser;
use ProtoneMedia\LaravelDuskFakes\Notifications\PersistentNotifications;
use Tests\DuskTestCase;
class PasswordResetTest extends DuskTestCase
{
use DatabaseMigrations;
use PersistentNotifications;
public function test_reset_password_link_can_be_requested()
{
$this->browse(function (Browser $browser) {
$user = User::factory()->create();
$browser->visit('/forgot-password')
->type('email', $user->email)
->press('Email Password Reset Link')
->waitForText('We have emailed your password reset link!');
Notification::assertSentTo($user, ResetPassword::class);
});
}
}
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Other Laravel packages
Laravel Analytics Event Tracking
: Laravel package to easily send events to Google Analytics.Laravel Blade On Demand
: Laravel package to compile Blade templates in memory.Laravel Cross Eloquent Search
: Laravel package to search through multiple Eloquent models.Laravel Eloquent Scope as Select
: Stop duplicating your Eloquent query scopes and constraints in PHP. This package lets you re-use your query scopes and constraints by adding them as a subquery.Laravel Eloquent Where Not
: This Laravel package allows you to flip/invert an Eloquent scope, or really any query constraint.Laravel Form Components
: Blade components to rapidly build forms with Tailwind CSS Custom Forms and Bootstrap 4. Supports validation, model binding, default values, translations, includes default vendor styling and fully customizable!Laravel MinIO Testing Tools
: This package provides a trait to run your tests against a MinIO S3 server.Laravel Mixins
: A collection of Laravel goodies.Laravel Paddle
: Paddle.com API integration for Laravel with support for webhooks/events.Laravel Splade
: Splade provides a super easy way to build Single Page Applications using Blade templates. Besides that magic SPA-feeling, it comes with more than ten components to sparkle your app and make it interactive, all without ever leaving Blade.Laravel Verify New Email
: This package adds support for verifying new email addresses: when a user updates its email address, it won't replace the old one until the new one is verified.Laravel WebDAV
: WebDAV driver for Laravel's Filesystem.Laravel XSS Protection Middleware
: Laravel Middleware to protect your app against Cross-site scripting (XSS). It sanitizes request input by utilising the Laravel Security package, and it can sanatize Blade echo statements as well.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.