O Other (Pre-Sale Questions, etc.) November 05, 2018
Login to reply
Milos Stojanovic Support Agent
3 years ago

Hey Cecil,

Thanks for sharing this! The latest version of Vanguard is not using anymore, but if someone is still using previous versions then they can update their tests to work properly with Mailtrap.

Kind regards,

Cecil Merrell
3 years ago

A while back, mailtrap changed the way the mail body was accessed through their api. I wanted to share how I solved the issue so others can keep using their amazing service. 

Using the register user with email confirmation test as an example.

public function test_register_user_with_email_confirmation()

            'reg_enabled' => true,
            'reg_email_confirmation' => true,
            'registration.captcha.enabled' => false,
            'tos' => false

        $data = [
            'email' => '',
            'username' => 'john.doe',
            'password' => '123123',
            'password_confirmation' => '123123'

        $this->postJson("/api/register", $data);

        $expected = array_except($data, ['password', 'password_confirmation']);

                'requires_email_confirmation' => true
            ->seeInDatabase('users', $expected);

        $token = User::where('email', $data['email'])->first()->confirmation_token;

        $message = $this->fetchInbox()[0];

        $this->assertEquals($data['email'], $message['to_email']);
        $this->assertEquals(config('mail.from.address'), $message['from_email']);
        $this->assertEquals(config(''), $message['from_name']);

        $messageBody = $this
            trans('app.thank_you_for_registering', ['app' => settings('app_name')]),
            route('register.confirm-email', $token),