Friday, March 3, 2017

Laravel/Dusk Swift_Events_EventListener not found

Laravel Framework 5.4.13

Basically i`m working with video tutorial: https://laracasts.com/series/phpunit-testing-in-laravel/episodes/12

But when i get to 4:30 in video i get this error:

Fatal error: Interface 'Tests\Browser\Swift_Events_EventListener' not found in C:\xampp\htdocs\XXX\tests\Browser\MailTracker.php on line 46 PHP Fatal error: Interface 'Tests\Browser\Swift_Events_EventListener' not found in C:\xampp\htdocs\XXX\tests\Browser\MailTracker.php on line 46

The code:

<?php

namespace Tests\Browser;

use App\User;
use Tests\DuskTestCase;
use Laravel\Dusk\Chrome;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Tests\TestCase;

class MailTracker extends DuskTestCase
{

    public function SetUp()
    {
        parent::SetUp();

        Mail::getSwiftMailer()
            ->registerPlugin(new TestingMailEventListener);
    }
    /**
     * A basic browser test example.
     *
     * @return void
     */
    public function testBasicExample()
    {
        Mail::raw('Hello', function ($message){
            $message->to('foo@bar.com');
            $message->from('bar@foo.com');
        });

    }

    protected function seeEmailWasSent()
    {

    }
}

class TestingMailEventListener implements Swift_Events_EventListener
{
    public function beforeSendPerformed($event)

    {
        $message = $event->getMessage();

        dd($message);
    }
}

Any ideas what is causing this problem?



via Igor Mandzopulos

Advertisement