code cleanup (#2700)

* fix doctrine definition
* do not count api calls as login
* remove unknown form options
* fix annotations
* cleanup deprecations in tests
This commit is contained in:
Kevin Papst
2021-08-07 01:36:59 +02:00
committed by GitHub
parent 3a7dba437c
commit e9986c92d6
9 changed files with 22 additions and 7 deletions

View File

@@ -255,7 +255,7 @@ class Timesheet implements EntityWithMetaFields, ExportItemInterface
* @Serializer\Expose() * @Serializer\Expose()
* @Serializer\Groups({"Default"}) * @Serializer\Groups({"Default"})
* *
* @ORM\Column(name="exported", type="boolean", nullable=false) * @ORM\Column(name="exported", type="boolean", nullable=false, options={"default": false})
* @Assert\NotNull() * @Assert\NotNull()
*/ */
private $exported = false; private $exported = false;

View File

@@ -13,6 +13,7 @@ use App\Entity\User;
use App\Event\UserInteractiveLoginEvent; use App\Event\UserInteractiveLoginEvent;
use App\Repository\UserRepository; use App\Repository\UserRepository;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Http\SecurityEvents; use Symfony\Component\Security\Http\SecurityEvents;
@@ -46,6 +47,12 @@ class LastLoginSubscriber implements EventSubscriberInterface
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event) public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{ {
// do not count API calls as logins
// this point could be used to add API rate limitation in the future
if ($event->getAuthenticationToken() instanceof PostAuthenticationGuardToken) {
return;
}
$user = $event->getAuthenticationToken()->getUser(); $user = $event->getAuthenticationToken()->getUser();
if ($user instanceof User) { if ($user instanceof User) {

View File

@@ -43,7 +43,6 @@ class ActivityRateForm extends AbstractRateForm
'data_class' => ActivityRate::class, 'data_class' => ActivityRate::class,
'csrf_protection' => true, 'csrf_protection' => true,
'csrf_field_name' => '_token', 'csrf_field_name' => '_token',
'expand_users' => true,
'csrf_token_id' => 'admin_customer_rate_edit', 'csrf_token_id' => 'admin_customer_rate_edit',
'attr' => [ 'attr' => [
'data-form-event' => 'kimai.activityUpdate' 'data-form-event' => 'kimai.activityUpdate'

View File

@@ -43,7 +43,6 @@ class CustomerRateForm extends AbstractRateForm
'data_class' => CustomerRate::class, 'data_class' => CustomerRate::class,
'csrf_protection' => true, 'csrf_protection' => true,
'csrf_field_name' => '_token', 'csrf_field_name' => '_token',
'expand_users' => true,
'csrf_token_id' => 'admin_customer_rate_edit', 'csrf_token_id' => 'admin_customer_rate_edit',
'attr' => [ 'attr' => [
'data-form-event' => 'kimai.customerUpdate' 'data-form-event' => 'kimai.customerUpdate'

View File

@@ -43,7 +43,6 @@ class ProjectRateForm extends AbstractRateForm
'data_class' => ProjectRate::class, 'data_class' => ProjectRate::class,
'csrf_protection' => true, 'csrf_protection' => true,
'csrf_field_name' => '_token', 'csrf_field_name' => '_token',
'expand_users' => true,
'csrf_token_id' => 'admin_project_rate_edit', 'csrf_token_id' => 'admin_project_rate_edit',
'attr' => [ 'attr' => [
'data-form-event' => 'kimai.projectUpdate' 'data-form-event' => 'kimai.projectUpdate'

View File

@@ -263,6 +263,7 @@ final class ServiceInvoice
/** /**
* @param InvoiceQuery $query * @param InvoiceQuery $query
* @return InvoiceItemInterface[] * @return InvoiceItemInterface[]
* @deprecated since 1.14 and will be removed with 2.0
*/ */
public function findInvoiceItems(InvoiceQuery $query): array public function findInvoiceItems(InvoiceQuery $query): array
{ {

View File

@@ -12,7 +12,7 @@ namespace App\Model\Statistic;
use App\Model\TimesheetCountedStatistic; use App\Model\TimesheetCountedStatistic;
/** /**
* @final * @internal
*/ */
class BudgetStatistic extends TimesheetCountedStatistic class BudgetStatistic extends TimesheetCountedStatistic
{ {

View File

@@ -240,7 +240,6 @@ class SystemConfigurationTest extends TestCase
{ {
$sut = $this->getSut($this->getDefaultSettings(), []); $sut = $this->getSut($this->getDefaultSettings(), []);
$this->assertEquals(99, $sut->getTimesheetActiveEntriesHardLimit()); $this->assertEquals(99, $sut->getTimesheetActiveEntriesHardLimit());
$this->assertEquals(99, $sut->getTimesheetActiveEntriesSoftLimit());
$this->assertFalse($sut->isTimesheetAllowFutureTimes()); $this->assertFalse($sut->isTimesheetAllowFutureTimes());
$this->assertFalse($sut->isTimesheetMarkdownEnabled()); $this->assertFalse($sut->isTimesheetMarkdownEnabled());
$this->assertEquals('duration_only', $sut->getTimesheetTrackingMode()); $this->assertEquals('duration_only', $sut->getTimesheetTrackingMode());
@@ -260,11 +259,19 @@ class SystemConfigurationTest extends TestCase
$this->assertEquals(5, $sut->getTimesheetIncrementEnd()); $this->assertEquals(5, $sut->getTimesheetIncrementEnd());
} }
/**
* @group legacy
*/
public function testDeprecatedSettingsWithoutLoader()
{
$sut = $this->getSut($this->getDefaultSettings(), []);
$this->assertEquals(99, $sut->getTimesheetActiveEntriesSoftLimit());
}
public function testTimesheetWithLoader() public function testTimesheetWithLoader()
{ {
$sut = $this->getSut($this->getDefaultSettings(), $this->getDefaultLoaderSettings()); $sut = $this->getSut($this->getDefaultSettings(), $this->getDefaultLoaderSettings());
$this->assertEquals(7, $sut->getTimesheetActiveEntriesHardLimit()); $this->assertEquals(7, $sut->getTimesheetActiveEntriesHardLimit());
$this->assertEquals(7, $sut->getTimesheetActiveEntriesSoftLimit());
$this->assertTrue($sut->isTimesheetAllowFutureTimes()); $this->assertTrue($sut->isTimesheetAllowFutureTimes());
$this->assertTrue($sut->isTimesheetMarkdownEnabled()); $this->assertTrue($sut->isTimesheetMarkdownEnabled());
$this->assertEquals('default', $sut->getTimesheetTrackingMode()); $this->assertEquals('default', $sut->getTimesheetTrackingMode());

View File

@@ -156,6 +156,9 @@ class ServiceInvoiceTest extends TestCase
self::assertEquals([], $items); self::assertEquals([], $items);
} }
/**
* @group legacy
*/
public function testFindInvoiceItemsWithCustomer() public function testFindInvoiceItemsWithCustomer()
{ {
$sut = $this->getSut([]); $sut = $this->getSut([]);