@@ -351,6 +351,132 @@ public function testCreateEventWithoutEventCoverDoesNotCreateImageRecord(): void
351351 $ this ->assertTrue (true );
352352 }
353353
354+ public function testCreateEventInheritsOrganizerFontFamily (): void
355+ {
356+ $ eventData = $ this ->createMockEventDomainObjectWithCategory ('MUSIC ' );
357+
358+ $ organizerSettings = Mockery::mock (OrganizerSettingDomainObject::class);
359+ $ organizerSettings ->shouldReceive ('getHomepageThemeSettings ' )
360+ ->andReturn ([
361+ 'accent ' => '#ff0000 ' ,
362+ 'background ' => '#ffffff ' ,
363+ 'mode ' => 'light ' ,
364+ 'background_type ' => HomepageBackgroundType::COLOR ->name ,
365+ 'font_family ' => 'Inter ' ,
366+ ]);
367+ $ organizerSettings ->shouldReceive ('getDefaultAttendeeDetailsCollectionMethod ' )
368+ ->andReturn ('per_order ' );
369+ $ organizerSettings ->shouldReceive ('getDefaultShowMarketingOptIn ' )
370+ ->andReturn (false );
371+ $ organizerSettings ->shouldReceive ('getDefaultPassPlatformFeeToBuyer ' )
372+ ->andReturn (false );
373+ $ organizerSettings ->shouldReceive ('getDefaultAllowAttendeeSelfEdit ' )
374+ ->andReturn (false );
375+
376+ $ organizer = $ this ->createMockOrganizerDomainObject ()
377+ ->shouldReceive ('getOrganizerSettings ' )
378+ ->andReturn ($ organizerSettings )
379+ ->getMock ();
380+
381+ $ this ->databaseManager ->shouldReceive ('transaction ' )->once ()->andReturnUsing (function ($ callback ) {
382+ return $ callback ();
383+ });
384+
385+ $ this ->organizerRepository
386+ ->shouldReceive ('loadRelation ' )
387+ ->with (OrganizerSettingDomainObject::class)
388+ ->once ()
389+ ->andReturnSelf ()
390+ ->getMock ()
391+ ->shouldReceive ('findFirstWhere ' )
392+ ->andReturn ($ organizer );
393+
394+ $ this ->eventRepository ->shouldReceive ('create ' )->andReturn ($ eventData );
395+
396+ $ this ->config ->shouldReceive ('get ' )
397+ ->with ('filesystems.public ' )
398+ ->andReturn ('public ' );
399+ $ this ->config ->shouldReceive ('get ' )
400+ ->with ('app.event_categories_cover_images_path ' )
401+ ->andReturn ('event-covers ' );
402+
403+ $ mockDisk = Mockery::mock ();
404+ $ mockDisk ->shouldReceive ('exists ' )
405+ ->with ('event-covers/MUSIC.jpg ' )
406+ ->andReturn (false );
407+
408+ $ this ->filesystemManager ->shouldReceive ('disk ' )
409+ ->with ('public ' )
410+ ->andReturn ($ mockDisk );
411+
412+ $ this ->eventSettingsRepository ->shouldReceive ('create ' )
413+ ->with (Mockery::on (function ($ arg ) {
414+ return isset ($ arg ['homepage_theme_settings ' ]['font_family ' ])
415+ && $ arg ['homepage_theme_settings ' ]['font_family ' ] === 'Inter ' ;
416+ }));
417+
418+ $ this ->eventStatisticsRepository ->shouldReceive ('create ' );
419+
420+ $ this ->purifier ->shouldReceive ('purify ' )->andReturn ('Test Description ' );
421+
422+ $ this ->createEventService ->createEvent ($ eventData );
423+
424+ $ this ->assertTrue (true );
425+ }
426+
427+ public function testCreateEventOmitsFontFamilyWhenOrganizerHasNone (): void
428+ {
429+ $ eventData = $ this ->createMockEventDomainObjectWithCategory ('MUSIC ' );
430+ $ organizer = $ this ->createMockOrganizerDomainObject ()
431+ ->shouldReceive ('getOrganizerSettings ' )
432+ ->andReturn (new OrganizerSettingDomainObject ())
433+ ->getMock ();
434+
435+ $ this ->databaseManager ->shouldReceive ('transaction ' )->once ()->andReturnUsing (function ($ callback ) {
436+ return $ callback ();
437+ });
438+
439+ $ this ->organizerRepository
440+ ->shouldReceive ('loadRelation ' )
441+ ->with (OrganizerSettingDomainObject::class)
442+ ->once ()
443+ ->andReturnSelf ()
444+ ->getMock ()
445+ ->shouldReceive ('findFirstWhere ' )
446+ ->andReturn ($ organizer );
447+
448+ $ this ->eventRepository ->shouldReceive ('create ' )->andReturn ($ eventData );
449+
450+ $ this ->config ->shouldReceive ('get ' )
451+ ->with ('filesystems.public ' )
452+ ->andReturn ('public ' );
453+ $ this ->config ->shouldReceive ('get ' )
454+ ->with ('app.event_categories_cover_images_path ' )
455+ ->andReturn ('event-covers ' );
456+
457+ $ mockDisk = Mockery::mock ();
458+ $ mockDisk ->shouldReceive ('exists ' )
459+ ->with ('event-covers/MUSIC.jpg ' )
460+ ->andReturn (false );
461+
462+ $ this ->filesystemManager ->shouldReceive ('disk ' )
463+ ->with ('public ' )
464+ ->andReturn ($ mockDisk );
465+
466+ $ this ->eventSettingsRepository ->shouldReceive ('create ' )
467+ ->with (Mockery::on (function ($ arg ) {
468+ return !array_key_exists ('font_family ' , $ arg ['homepage_theme_settings ' ] ?? []);
469+ }));
470+
471+ $ this ->eventStatisticsRepository ->shouldReceive ('create ' );
472+
473+ $ this ->purifier ->shouldReceive ('purify ' )->andReturn ('Test Description ' );
474+
475+ $ this ->createEventService ->createEvent ($ eventData );
476+
477+ $ this ->assertTrue (true );
478+ }
479+
354480 private function createMockEventDomainObject (): EventDomainObject
355481 {
356482 return Mockery::mock (EventDomainObject::class, static function ($ mock ) {
0 commit comments