1111
1212namespace Test \Mail ;
1313
14- use OC \ Activity \ Event ;
14+
1515use OC \Mail \EMailTemplate ;
1616use OC \Mail \Mailer ;
1717use OCP \Defaults ;
18+ use OCP \EventDispatcher \IEventDispatcher ;
1819use OCP \IConfig ;
1920use OCP \IL10N ;
2021use OCP \ILogger ;
2122use OCP \IURLGenerator ;
23+ use OCP \Mail \Events \BeforeMessageSent ;
2224use OCP \Mail \IMessage ;
2325use Test \TestCase ;
2426use Swift_SwiftException ;
25- use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
26- use Symfony \Component \EventDispatcher \GenericEvent ;
2727
2828class MailerTest extends TestCase {
2929 /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
@@ -38,9 +38,10 @@ class MailerTest extends TestCase {
3838 private $ l10n ;
3939 /** @var Mailer */
4040 private $ mailer ;
41- /** @var EventDispatcherInterface */
41+ /** @var IEventDispatcher */
4242 private $ dispatcher ;
4343
44+
4445 protected function setUp (): void {
4546 parent ::setUp ();
4647
@@ -49,7 +50,7 @@ protected function setUp(): void {
4950 $ this ->logger = $ this ->createMock (ILogger::class);
5051 $ this ->urlGenerator = $ this ->createMock (IURLGenerator::class);
5152 $ this ->l10n = $ this ->createMock (IL10N ::class);
52- $ this ->dispatcher = $ this ->createMock (EventDispatcherInterface ::class);
53+ $ this ->dispatcher = $ this ->createMock (IEventDispatcher ::class);
5354 $ this ->mailer = new Mailer (
5455 $ this ->config ,
5556 $ this ->logger ,
@@ -136,9 +137,9 @@ public function testEvents() {
136137
137138
138139 $ this ->dispatcher ->expects ($ this ->at (0 ))
139- ->method ('dispatch ' )
140- ->with (' \OC\Mail::preSendMessage ' , $ this ->callback (function (GenericEvent $ e ) use ($ test , $ message , &$ count ) {
141- $ m = $ e ->getSubject ( ' message ' );
140+ ->method ('dispatchTyped ' )
141+ ->with ($ this ->callback (function (BeforeMessageSent $ e ) use ($ test , $ message , &$ count ) {
142+ $ m = $ e ->getMessage ( );
142143 $ test ->assertEquals ($ message , $ m );
143144 $ count ++;
144145 return $ m === $ message ;
0 commit comments