Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)

This commit is contained in:
Kevin Papst
2022-12-31 21:19:55 +01:00
committed by GitHub
parent 95e06746bd
commit 90a0fd8a22
2164 changed files with 83700 additions and 86426 deletions

View File

@@ -1,23 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber\Actions;
use App\EventSubscriber\Actions\CalendarSubscriber;
/**
* @covers \App\EventSubscriber\Actions\CalendarSubscriber
*/
class CalendarSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(CalendarSubscriber::class, 'calendar');
}
}

View File

@@ -1,23 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber\Actions;
use App\EventSubscriber\Actions\ExportSubscriber;
/**
* @covers \App\EventSubscriber\Actions\ExportSubscriber
*/
class ExportSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(ExportSubscriber::class, 'export');
}
}

View File

@@ -18,6 +18,6 @@ class InvoiceArchiveSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(InvoiceArchiveSubscriber::class, 'invoice_details');
$this->assertGetSubscribedEvent(InvoiceArchiveSubscriber::class, 'invoice_archive');
}
}

View File

@@ -9,10 +9,10 @@
namespace App\Tests\EventSubscriber\Actions;
use App\Entity\InvoiceDocument;
use App\Entity\User;
use App\Event\PageActionsEvent;
use App\EventSubscriber\Actions\InvoiceDocumentSubscriber;
use App\Model\InvoiceDocument;
/**
* @covers \App\EventSubscriber\Actions\InvoiceDocumentSubscriber

View File

@@ -1,23 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber\Actions;
use App\EventSubscriber\Actions\InvoiceTemplateUploadSubscriber;
/**
* @covers \App\EventSubscriber\Actions\InvoiceTemplateUploadSubscriber
*/
class InvoiceTemplateUploadSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(InvoiceTemplateUploadSubscriber::class, 'invoice_upload');
}
}

View File

@@ -1,23 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber\Actions;
use App\EventSubscriber\Actions\InvoicesSubscriber;
/**
* @covers \App\EventSubscriber\Actions\InvoicesSubscriber
*/
class InvoicesSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(InvoicesSubscriber::class, 'invoices');
}
}

View File

@@ -1,23 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber\Actions;
use App\EventSubscriber\Actions\PluginsSubscriber;
/**
* @covers \App\EventSubscriber\Actions\PluginsSubscriber
*/
class PluginsSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(PluginsSubscriber::class, 'plugins');
}
}

View File

@@ -1,23 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber\Actions;
use App\EventSubscriber\Actions\QuickEntrySubscriber;
/**
* @covers \App\EventSubscriber\Actions\QuickEntrySubscriber
*/
class QuickEntrySubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(QuickEntrySubscriber::class, 'weekly_times');
}
}

View File

@@ -1,23 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber\Actions;
use App\EventSubscriber\Actions\ReportingSubscriber;
/**
* @covers \App\EventSubscriber\Actions\ReportingSubscriber
*/
class ReportingSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(ReportingSubscriber::class, 'reporting');
}
}

View File

@@ -1,23 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber\Actions;
use App\EventSubscriber\Actions\SystemConfigurationSubscriber;
/**
* @covers \App\EventSubscriber\Actions\SystemConfigurationSubscriber
*/
class SystemConfigurationSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(SystemConfigurationSubscriber::class, 'system_configuration');
}
}

View File

@@ -1,23 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber\Actions;
use App\EventSubscriber\Actions\TimesheetMultiUpdateSubscriber;
/**
* @covers \App\EventSubscriber\Actions\TimesheetMultiUpdateSubscriber
*/
class TimesheetMultiUpdateSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(TimesheetMultiUpdateSubscriber::class, 'timesheets_multi_update');
}
}

View File

@@ -1,25 +0,0 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber\Actions;
use App\EventSubscriber\Actions\TimesheetTeamMultiUpdateSubscriber;
/**
* @covers \App\EventSubscriber\Actions\AbstractActionsSubscriber
* @covers \App\EventSubscriber\Actions\TimesheetTeamMultiUpdateSubscriber
* @covers \App\EventSubscriber\Actions\TimesheetTeamMultiUpdateSubscriber
*/
class TimesheetTeamMultiUpdateSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(TimesheetTeamMultiUpdateSubscriber::class, 'timesheets_team_multi_update');
}
}

View File

@@ -0,0 +1,112 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber;
use App\EventSubscriber\AjaxAuthenticationSubscriber;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\AuthenticationExpiredException;
/**
* @covers \App\EventSubscriber\AjaxAuthenticationSubscriber
*/
class AjaxAuthenticationSubscriberTest extends TestCase
{
public function testGetSubscribedEvents()
{
$events = AjaxAuthenticationSubscriber::getSubscribedEvents();
$this->assertArrayHasKey(KernelEvents::EXCEPTION, $events);
$methodName = $events[KernelEvents::EXCEPTION][0];
$this->assertTrue(method_exists(AjaxAuthenticationSubscriber::class, $methodName));
}
public function getTestHeader()
{
yield ['XMLHttpRequest'];
yield ['Kimai'];
}
/**
* @dataProvider getTestHeader
*/
public function testAuthenticationExpiredException(string $requestedWith)
{
$sut = new AjaxAuthenticationSubscriber();
$exception = new AuthenticationExpiredException();
$kernel = $this->createMock(HttpKernelInterface::class);
$request = new Request();
$request->initialize([], [], [], [], [], ['HTTP_X-Requested-With' => $requestedWith]);
$event = new ExceptionEvent($kernel, $request, 1, $exception);
$sut->onCoreException($event);
$response = $event->getResponse();
self::assertNotNull($response);
self::assertEquals('Session expired', $response->getContent());
self::assertEquals(403, $response->getStatusCode());
self::assertTrue($response->headers->has('Login-Required'));
self::assertEquals('1', $response->headers->get('Login-Required'));
}
/**
* @dataProvider getTestHeader
*/
public function testAuthenticationException(string $requestedWith)
{
$sut = new AjaxAuthenticationSubscriber();
$exception = new AuthenticationException();
$kernel = $this->createMock(HttpKernelInterface::class);
$request = new Request();
$request->initialize([], [], [], [], [], ['HTTP_X-Requested-With' => $requestedWith]);
$event = new ExceptionEvent($kernel, $request, 1, $exception);
$sut->onCoreException($event);
$response = $event->getResponse();
self::assertNotNull($response);
self::assertEquals('Authentication problem', $response->getContent());
self::assertEquals(403, $response->getStatusCode());
self::assertTrue($response->headers->has('Login-Required'));
self::assertEquals('1', $response->headers->get('Login-Required'));
}
/**
* @dataProvider getTestHeader
*/
public function testAccessDeniedException(string $requestedWith)
{
$sut = new AjaxAuthenticationSubscriber();
$exception = new AccessDeniedException();
$kernel = $this->createMock(HttpKernelInterface::class);
$request = new Request();
$request->initialize([], [], [], [], [], ['HTTP_X-Requested-With' => $requestedWith]);
$event = new ExceptionEvent($kernel, $request, 1, $exception);
$sut->onCoreException($event);
$response = $event->getResponse();
self::assertNotNull($response);
self::assertEquals('Access denied', $response->getContent());
self::assertEquals(403, $response->getStatusCode());
self::assertTrue($response->headers->has('Login-Required'));
self::assertEquals('1', $response->headers->get('Login-Required'));
}
}

View File

@@ -16,8 +16,9 @@ use App\Repository\UserRepository;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Http\SecurityEvents;
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Event\LoginSuccessEvent;
/**
* @covers \App\EventSubscriber\LastLoginSubscriber
@@ -32,8 +33,8 @@ class LastLoginSubscriberTest extends TestCase
$methodName = $events[UserInteractiveLoginEvent::class];
$this->assertTrue(method_exists(LastLoginSubscriber::class, $methodName));
$this->assertArrayHasKey(SecurityEvents::INTERACTIVE_LOGIN, $events);
$methodName = $events[SecurityEvents::INTERACTIVE_LOGIN];
$this->assertArrayHasKey(LoginSuccessEvent::class, $events);
$methodName = $events[LoginSuccessEvent::class];
$this->assertTrue(method_exists(LastLoginSubscriber::class, $methodName));
}
@@ -52,7 +53,7 @@ class LastLoginSubscriberTest extends TestCase
self::assertNotNull($user->getLastLogin());
}
public function testOnSecurityInteractiveLoginWithUser()
public function testOnLoginSuccessWithUser()
{
$repository = $this->createMock(UserRepository::class);
$repository->expects($this->once())->method('saveUser');
@@ -61,16 +62,11 @@ class LastLoginSubscriberTest extends TestCase
$user = new User();
self::assertNull($user->getLastLogin());
$event = new InteractiveLoginEvent(new Request(), new UsernamePasswordToken($user, [], 'sdf'));
$sut->onSecurityInteractiveLogin($event);
$authenticator = $this->createMock(AuthenticatorInterface::class);
$passport = $this->createMock(Passport::class);
$passport->method('getUser')->willReturn($user);
$event = new LoginSuccessEvent($authenticator, $passport, new UsernamePasswordToken($user, 'sdf'), new Request(), null, 'xyz');
$sut->onFormLogin($event);
self::assertNotNull($user->getLastLogin());
$user = new User();
self::assertNull($user->getLastLogin());
$event = new InteractiveLoginEvent(new Request(), new UsernamePasswordToken('foo', 'bar', 'sdf'));
$sut->onSecurityInteractiveLogin($event);
self::assertNull($user->getLastLogin());
}
}

View File

@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber;
use App\Event\ConfigureMainMenuEvent;
use App\EventSubscriber\MenuFavoritesSubscriber;
use App\EventSubscriber\MenuSubscriber;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\EventSubscriber\MenuFavoritesSubscriber
*/
class MenuFavoritesSubscriberTest extends TestCase
{
public function testGetSubscribedEvents(): void
{
$events = MenuFavoritesSubscriber::getSubscribedEvents();
$this->assertArrayHasKey(ConfigureMainMenuEvent::class, $events);
$methodName = $events[ConfigureMainMenuEvent::class][0];
self::assertIsString($methodName);
$this->assertTrue(method_exists(MenuSubscriber::class, $methodName));
}
}

View File

@@ -39,7 +39,7 @@ class PagerfantaExceptionSubscriberTest extends TestCase
$kernel = $this->createMock(HttpKernelInterface::class);
$request = $this->createMock(Request::class);
$exception = new \Exception();
$requestType = HttpKernelInterface::MASTER_REQUEST;
$requestType = HttpKernelInterface::MAIN_REQUEST;
$event = new ExceptionEvent($kernel, $request, $requestType, $exception);
$sut->onCoreException($event);

View File

@@ -0,0 +1,131 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber;
use App\Entity\User;
use App\EventSubscriber\LastLoginSubscriber;
use App\EventSubscriber\ProfileSubscriber;
use App\Utils\ProfileManager;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Event\LoginSuccessEvent;
/**
* @covers \App\EventSubscriber\ProfileSubscriber
*/
class ProfileSubscriberTest extends TestCase
{
public function testGetSubscribedEvents()
{
$events = ProfileSubscriber::getSubscribedEvents();
$this->assertArrayHasKey(LoginSuccessEvent::class, $events);
$methodName = $events[LoginSuccessEvent::class];
$this->assertTrue(method_exists(LastLoginSubscriber::class, $methodName));
}
public function testOnLoginSuccessWithoutProfileSetsDesktop()
{
$manager = new ProfileManager();
$sut = new ProfileSubscriber($manager);
$request = new Request();
$session = new Session(new MockFileSessionStorage());
$request->setSession($session);
self::assertNull($session->get(ProfileManager::SESSION_PROFILE));
$user = new User();
$authenticator = $this->createMock(AuthenticatorInterface::class);
$passport = $this->createMock(Passport::class);
$passport->method('getUser')->willReturn($user);
$event = new LoginSuccessEvent($authenticator, $passport, new UsernamePasswordToken($user, 'sdf'), $request, null, 'xyz');
$sut->onFormLogin($event);
self::assertNull($session->get(ProfileManager::SESSION_PROFILE));
self::assertEquals(ProfileManager::PROFILE_DESKTOP, $manager->getProfileFromSession($session));
}
public function testOnLoginSuccessWithProfile()
{
$manager = new ProfileManager();
$sut = new ProfileSubscriber($manager);
$request = new Request();
$session = new Session(new MockFileSessionStorage());
$request->setSession($session);
$request->cookies->set(ProfileManager::COOKIE_PROFILE, 'mobile');
self::assertNull($session->get(ProfileManager::SESSION_PROFILE));
$user = new User();
self::assertNull($user->getLastLogin());
$authenticator = $this->createMock(AuthenticatorInterface::class);
$passport = $this->createMock(Passport::class);
$passport->method('getUser')->willReturn($user);
$event = new LoginSuccessEvent($authenticator, $passport, new UsernamePasswordToken($user, 'sdf'), $request, null, 'xyz');
$sut->onFormLogin($event);
self::assertNotNull($session->get(ProfileManager::SESSION_PROFILE));
self::assertEquals(ProfileManager::PROFILE_MOBILE, $session->get(ProfileManager::SESSION_PROFILE));
self::assertEquals(ProfileManager::PROFILE_MOBILE, $manager->getProfileFromSession($session));
}
public function getInvalidCookies()
{
return [
['MOBILE'],
['mobilE'],
['mobile2'],
['mobile2'],
['foo'],
['mobile '],
[' desktop'],
['DESKTOP'],
// the next two ones are misleading: default value "desktop" will not be set and session value will be removed
['desktop'],
[ProfileManager::PROFILE_DESKTOP],
];
}
/**
* @dataProvider getInvalidCookies
*/
public function testOnLoginSuccessWithInvalidProfile(string $cookieValue)
{
$manager = new ProfileManager();
$sut = new ProfileSubscriber($manager);
$request = new Request();
$session = new Session(new MockFileSessionStorage());
$request->setSession($session);
$request->cookies->set(ProfileManager::COOKIE_PROFILE, $cookieValue);
self::assertNull($session->get(ProfileManager::SESSION_PROFILE));
$user = new User();
self::assertNull($user->getLastLogin());
$authenticator = $this->createMock(AuthenticatorInterface::class);
$passport = $this->createMock(Passport::class);
$passport->method('getUser')->willReturn($user);
$event = new LoginSuccessEvent($authenticator, $passport, new UsernamePasswordToken($user, 'sdf'), $request, null, 'xyz');
$sut->onFormLogin($event);
self::assertNull($session->get(ProfileManager::SESSION_PROFILE));
self::assertEquals(ProfileManager::PROFILE_DESKTOP, $manager->getProfileFromSession($session));
}
}

View File

@@ -9,8 +9,8 @@
namespace App\Tests\EventSubscriber;
use App\Configuration\LocaleService;
use App\EventSubscriber\RedirectToLocaleSubscriber;
use App\Utils\LanguageService;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\RequestEvent;
@@ -25,7 +25,7 @@ class RedirectToLocaleSubscriberTest extends TestCase
public function testConstruct()
{
$urlGenerator = $this->createMock(UrlGeneratorInterface::class);
$sut = new RedirectToLocaleSubscriber($urlGenerator, new LanguageService('de|en'));
$sut = new RedirectToLocaleSubscriber($urlGenerator, new LocaleService(['de', 'en']));
self::assertEquals([KernelEvents::REQUEST => ['onKernelRequest']], RedirectToLocaleSubscriber::getSubscribedEvents());

View File

@@ -0,0 +1,28 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber;
use App\EventSubscriber\UserDetailsSubscriber;
use KevinPapst\TablerBundle\Event\UserDetailsEvent;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\EventSubscriber\UserDetailsSubscriber
*/
class UserDetailsSubscriberTest extends TestCase
{
public function testGetSubscribedEvents()
{
$events = UserDetailsSubscriber::getSubscribedEvents();
$this->assertArrayHasKey(UserDetailsEvent::class, $events);
$methodName = $events[UserDetailsEvent::class][0];
$this->assertTrue(method_exists(UserDetailsSubscriber::class, $methodName));
}
}

View File

@@ -9,11 +9,11 @@
namespace App\Tests\EventSubscriber;
use App\Configuration\SystemConfiguration;
use App\Entity\User;
use App\Entity\UserPreference;
use App\Event\PrepareUserEvent;
use App\EventSubscriber\UserPreferenceSubscriber;
use App\Tests\Mocks\SystemConfigurationFactory;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
@@ -30,18 +30,15 @@ class UserPreferenceSubscriberTest extends TestCase
'language',
'first_weekday',
'skin',
'hours_24',
'theme.layout',
'theme.collapsed_sidebar',
'theme.update_browser_title',
'calendar.initial_view',
'reporting.initial_view',
'login.initial_view',
'timesheet.daily_stats',
'timesheet.export_decimal',
'update_browser_title',
'calendar_initial_view',
'login_initial_view',
'daily_stats',
'export_decimal',
'favorite_routes',
];
public function testGetSubscribedEvents()
public function testGetSubscribedEvents(): void
{
$events = UserPreferenceSubscriber::getSubscribedEvents();
$this->assertArrayHasKey(PrepareUserEvent::class, $events);
@@ -49,7 +46,7 @@ class UserPreferenceSubscriberTest extends TestCase
$this->assertTrue(method_exists(UserPreferenceSubscriber::class, $methodName));
}
public function testWithHourlyRateAllowed()
public function testWithHourlyRateAllowed(): void
{
$sut = $this->getSubscriber(true);
$user = new User();
@@ -68,7 +65,6 @@ class UserPreferenceSubscriberTest extends TestCase
switch ($pref->getName()) {
case UserPreference::HOURLY_RATE:
case UserPreference::INTERNAL_RATE:
case 'reporting.initial_view':
self::assertTrue($pref->isEnabled());
break;
@@ -82,7 +78,7 @@ class UserPreferenceSubscriberTest extends TestCase
}
}
public function testWithHourlyRateNotAllowed()
public function testWithHourlyRateNotAllowed(): void
{
$sut = $this->getSubscriber(false);
$user = new User();
@@ -99,9 +95,8 @@ class UserPreferenceSubscriberTest extends TestCase
switch ($pref->getName()) {
case UserPreference::HOURLY_RATE:
case UserPreference::INTERNAL_RATE:
case 'reporting.initial_view':
self::assertFalse($pref->isEnabled());
break;
break;
default:
self::assertTrue($pref->isEnabled());
@@ -109,13 +104,20 @@ class UserPreferenceSubscriberTest extends TestCase
}
}
protected function getSubscriber(bool $seeHourlyRate)
protected function getSubscriber(bool $seeHourlyRate): UserPreferenceSubscriber
{
$authMock = $this->createMock(AuthorizationCheckerInterface::class);
$authMock->method('isGranted')->willReturn($seeHourlyRate);
$eventMock = $this->createMock(EventDispatcherInterface::class);
$formConfigMock = $this->createMock(SystemConfiguration::class);
$formConfigMock = SystemConfigurationFactory::createStub([
'defaults' => [
'user' => [
'language' => 'en',
'currency' => 'EUR',
]
]
]);
return new UserPreferenceSubscriber($eventMock, $authMock, $formConfigMock);
}

View File

@@ -0,0 +1,28 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\EventSubscriber;
use App\EventSubscriber\WizardSubscriber;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* @covers \App\EventSubscriber\WizardSubscriber
*/
class WizardSubscriberTest extends TestCase
{
public function testGetSubscribedEvents()
{
$events = WizardSubscriber::getSubscribedEvents();
$this->assertArrayHasKey(KernelEvents::REQUEST, $events);
$methodName = $events[KernelEvents::REQUEST][0];
$this->assertTrue(method_exists(WizardSubscriber::class, $methodName));
}
}