release 2.0 beta 2 (#3757)

* do not traverse into invoice template subdirectories (#3735)
* fix security open api definition
* fix currency can be null, removed fluent interface
* merged release 1.30.3
* allow to pre-fill timesheet metafields via URL
* fix api description
* added test accounts with simpler names and password
* upgrade to Symfony 6.2
* removed FrameworkExtraBundle (by Sensio) and replaced with new native SF annotations
* fixed symfony 6.2 deprecations
* fixed #3768
This commit is contained in:
Kevin Papst
2023-01-18 14:47:48 +01:00
committed by GitHub
parent 6e0500972e
commit 0e91dd886e
141 changed files with 1600 additions and 1415 deletions

View File

@@ -18,10 +18,11 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\ColorChoices
* @covers \App\Validator\Constraints\ColorChoicesValidator
* @extends ConstraintValidatorTestCase<ColorChoicesValidator>
*/
class ColorChoicesValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ColorChoicesValidator
{
return new ColorChoicesValidator();
}

View File

@@ -18,10 +18,11 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\DateTimeFormat
* @covers \App\Validator\Constraints\DateTimeFormatValidator
* @extends ConstraintValidatorTestCase<DateTimeFormatValidator>
*/
class DateTimeFormatValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): DateTimeFormatValidator
{
return new DateTimeFormatValidator();
}

View File

@@ -19,10 +19,11 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\Duration
* @covers \App\Validator\Constraints\DurationValidator
* @extends ConstraintValidatorTestCase<DurationValidator>
*/
class DurationValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): DurationValidator
{
return new DurationValidator();
}

View File

@@ -18,10 +18,11 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\HexColor
* @covers \App\Validator\Constraints\HexColorValidator
* @extends ConstraintValidatorTestCase<HexColorValidator>
*/
class HexColorValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): HexColorValidator
{
return new HexColorValidator();
}

View File

@@ -19,10 +19,11 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\Project
* @covers \App\Validator\Constraints\ProjectValidator
* @extends ConstraintValidatorTestCase<ProjectValidator>
*/
class ProjectValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): ProjectValidator
{
return new ProjectValidator();
}

View File

@@ -22,10 +22,11 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\QuickEntryModel
* @covers \App\Validator\Constraints\QuickEntryModelValidator
* @extends ConstraintValidatorTestCase<QuickEntryModelValidator>
*/
class QuickEntryModelValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): QuickEntryModelValidator
{
return new QuickEntryModelValidator();
}

View File

@@ -14,23 +14,24 @@ use App\Entity\Timesheet;
use App\Validator\Constraints\QuickEntryTimesheet;
use App\Validator\Constraints\QuickEntryTimesheetValidator;
use App\Validator\Constraints\TimesheetBasic;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\QuickEntryTimesheet
* @covers \App\Validator\Constraints\QuickEntryTimesheetValidator
* @extends ConstraintValidatorTestCase<QuickEntryTimesheetValidator>
*/
class QuickEntryTimesheetValidatorTest extends ConstraintValidatorTestCase
{
protected function createConstraint(): Constraint
protected function createConstraint(): QuickEntryTimesheet
{
return new QuickEntryTimesheet();
}
protected function createValidator()
protected function createValidator(): ConstraintValidatorInterface
{
return new QuickEntryTimesheetValidator([new TimesheetBasic()]);
}

View File

@@ -20,6 +20,7 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\RoleName
* @covers \App\Validator\Constraints\RoleNameValidator
* @extends ConstraintValidatorTestCase<RoleNameValidator>
*/
class RoleNameValidatorTest extends ConstraintValidatorTestCase
{

View File

@@ -20,10 +20,11 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\Role
* @covers \App\Validator\Constraints\RoleValidator
* @extends ConstraintValidatorTestCase<RoleValidator>
*/
class RoleValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): RoleValidator
{
$factory = new RoleServiceFactory($this);
$roleService = $factory->create();

View File

@@ -21,10 +21,11 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\Team
* @covers \App\Validator\Constraints\TeamValidator
* @extends ConstraintValidatorTestCase<TeamValidator>
*/
class TeamValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): TeamValidator
{
return new TeamValidator();
}
@@ -33,7 +34,7 @@ class TeamValidatorTest extends ConstraintValidatorTestCase
{
$this->expectException(UnexpectedTypeException::class);
$this->validator->validate('foo', new NotBlank());
$this->validator->validate('foo', new NotBlank()); // @phpstan-ignore-line
}
public function testMissingTeamlead()

View File

@@ -19,10 +19,11 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\TimeFormat
* @covers \App\Validator\Constraints\TimeFormatValidator
* @extends ConstraintValidatorTestCase<TimeFormatValidator>
*/
class TimeFormatValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): TimeFormatValidator
{
return new TimeFormatValidator();
}

View File

@@ -23,15 +23,16 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\TimesheetBasic
* @covers \App\Validator\Constraints\TimesheetBasicValidator
* @extends ConstraintValidatorTestCase<TimesheetBasicValidator>
*/
class TimesheetBasicValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): TimesheetBasicValidator
{
return $this->createMyValidator();
}
protected function createMyValidator()
protected function createMyValidator(): TimesheetBasicValidator
{
$configuration = SystemConfigurationFactory::createStub(['timesheet' => ['rules' => ['require_activity' => true]]]);

View File

@@ -40,10 +40,14 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\TimesheetBudgetUsed
* @covers \App\Validator\Constraints\TimesheetBudgetUsedValidator
* @extends ConstraintValidatorTestCase<TimesheetBudgetUsedValidator>
*/
class TimesheetBudgetUsedValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator(bool $isAllowed = false, ?ActivityBudgetStatisticModel $activityStatisticModel = null, ?ProjectBudgetStatisticModel $projectStatisticModel = null, ?CustomerBudgetStatisticModel $customerStatisticModel = null, ?array $rawData = null, ?Rate $rate = null)
/**
* @param array<mixed>|null $rawData
*/
protected function createValidator(bool $isAllowed = false, ?ActivityBudgetStatisticModel $activityStatisticModel = null, ?ProjectBudgetStatisticModel $projectStatisticModel = null, ?CustomerBudgetStatisticModel $customerStatisticModel = null, ?array $rawData = null, ?Rate $rate = null): TimesheetBudgetUsedValidator
{
$configuration = SystemConfigurationFactory::createStub(['timesheet' => ['rules' => ['allow_overbooking_budget' => $isAllowed]]]);
@@ -117,7 +121,7 @@ class TimesheetBudgetUsedValidatorTest extends ConstraintValidatorTestCase
{
$this->expectException(UnexpectedTypeException::class);
$this->validator->validate('foo', new TimesheetBudgetUsed());
$this->validator->validate('foo', new TimesheetBudgetUsed()); // @phpstan-ignore-line
}
public function testWithMissingEnd()

View File

@@ -13,7 +13,7 @@ use App\Entity\Timesheet;
use App\Entity\User;
use App\Validator\Constraints\TimesheetExported;
use App\Validator\Constraints\TimesheetExportedValidator;
use Symfony\Component\Security\Core\Security;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -21,15 +21,16 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\TimesheetExported
* @covers \App\Validator\Constraints\TimesheetExportedValidator
* @extends ConstraintValidatorTestCase<TimesheetExportedValidator>
*/
class TimesheetExportedValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): TimesheetExportedValidator
{
return $this->createMyValidator(true);
}
protected function createMyValidator(bool $allowEdit)
protected function createMyValidator(bool $allowEdit): TimesheetExportedValidator
{
$auth = $this->createMock(Security::class);
$auth->method('getUser')->willReturn(new User());
@@ -58,7 +59,7 @@ class TimesheetExportedValidatorTest extends ConstraintValidatorTestCase
{
$this->expectException(UnexpectedTypeException::class);
$this->validator->validate(new NotBlank(), new TimesheetExported(['message' => 'myMessage']));
$this->validator->validate(new NotBlank(), new TimesheetExported(['message' => 'myMessage'])); // @phpstan-ignore-line
}
public function testTriggersOnMissingPermission()

View File

@@ -21,15 +21,16 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\TimesheetFutureTimes
* @covers \App\Validator\Constraints\TimesheetFutureTimesValidator
* @extends ConstraintValidatorTestCase<TimesheetFutureTimesValidator>
*/
class TimesheetFutureTimesValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): TimesheetFutureTimesValidator
{
return $this->createMyValidator(false);
}
protected function createMyValidator(bool $allowFutureTimes = false)
protected function createMyValidator(bool $allowFutureTimes = false): TimesheetFutureTimesValidator
{
$loader = $this->createMock(ConfigLoaderInterface::class);
$config = SystemConfigurationFactory::create($loader, [
@@ -59,7 +60,7 @@ class TimesheetFutureTimesValidatorTest extends ConstraintValidatorTestCase
{
$this->expectException(UnexpectedTypeException::class);
$this->validator->validate(new NotBlank(), new TimesheetFutureTimes(['message' => 'myMessage']));
$this->validator->validate(new NotBlank(), new TimesheetFutureTimes(['message' => 'myMessage'])); // @phpstan-ignore-line
}
public function testFutureBeginIsDisallowed()

View File

@@ -16,7 +16,7 @@ use App\Tests\Mocks\SystemConfigurationFactory;
use App\Timesheet\LockdownService;
use App\Validator\Constraints\TimesheetLockdown;
use App\Validator\Constraints\TimesheetLockdownValidator;
use Symfony\Component\Security\Core\Security;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -24,15 +24,16 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\TimesheetLockdown
* @covers \App\Validator\Constraints\TimesheetLockdownValidator
* @extends ConstraintValidatorTestCase<TimesheetLockdownValidator>
*/
class TimesheetLockdownValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): TimesheetLockdownValidator
{
return $this->createMyValidator(false, false, null, null, null);
}
protected function createMyValidator(bool $allowOverwriteFull, bool $allowOverwriteGrace, ?string $start, ?string $end, ?string $grace)
protected function createMyValidator(bool $allowOverwriteFull, bool $allowOverwriteGrace, ?string $start, ?string $end, ?string $grace): TimesheetLockdownValidator
{
$auth = $this->createMock(Security::class);
$auth->method('getUser')->willReturn(new User());
@@ -74,7 +75,7 @@ class TimesheetLockdownValidatorTest extends ConstraintValidatorTestCase
{
$this->expectException(UnexpectedTypeException::class);
$this->validator->validate(new NotBlank(), new TimesheetLockdown(['message' => 'myMessage']));
$this->validator->validate(new NotBlank(), new TimesheetLockdown(['message' => 'myMessage'])); // @phpstan-ignore-line
}
public function testValidatorWithoutNowConstraint()

View File

@@ -21,15 +21,16 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\TimesheetLongRunning
* @covers \App\Validator\Constraints\TimesheetLongRunningValidator
* @extends ConstraintValidatorTestCase<TimesheetLongRunningValidator>
*/
class TimesheetLongRunningValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): TimesheetLongRunningValidator
{
return $this->createMyValidator(120);
}
protected function createMyValidator(int $minutes)
protected function createMyValidator(int $minutes): TimesheetLongRunningValidator
{
$loader = $this->createMock(ConfigLoaderInterface::class);
$config = SystemConfigurationFactory::create($loader, [
@@ -54,7 +55,7 @@ class TimesheetLongRunningValidatorTest extends ConstraintValidatorTestCase
{
$this->expectException(UnexpectedTypeException::class);
$this->validator->validate(new NotBlank(), new TimesheetLongRunning(['message' => 'myMessage']));
$this->validator->validate(new NotBlank(), new TimesheetLongRunning(['message' => 'myMessage'])); // @phpstan-ignore-line
}
public function testLongRunningTriggers()

View File

@@ -22,10 +22,11 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\TimesheetMultiUpdate
* @covers \App\Validator\Constraints\TimesheetMultiUpdateValidator
* @extends ConstraintValidatorTestCase<TimesheetMultiUpdateValidator>
*/
class TimesheetMultiUpdateValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator($isGranted = true)
protected function createValidator(): TimesheetMultiUpdateValidator
{
return new TimesheetMultiUpdateValidator();
}

View File

@@ -19,10 +19,11 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\TimesheetMultiUser
* @covers \App\Validator\Constraints\TimesheetMultiUserValidator
* @extends ConstraintValidatorTestCase<TimesheetMultiUserValidator>
*/
class TimesheetMultiUserValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator($isGranted = true)
protected function createValidator(): TimesheetMultiUserValidator
{
return new TimesheetMultiUserValidator();
}

View File

@@ -22,15 +22,16 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\TimesheetOverlapping
* @covers \App\Validator\Constraints\TimesheetOverlappingValidator
* @extends ConstraintValidatorTestCase<TimesheetOverlappingValidator>
*/
class TimesheetOverlappingValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): TimesheetOverlappingValidator
{
return $this->createMyValidator(false, true);
}
protected function createMyValidator(bool $allowOverlappingRecords = false, bool $hasRecords = true)
protected function createMyValidator(bool $allowOverlappingRecords = false, bool $hasRecords = true): TimesheetOverlappingValidator
{
$loader = $this->createMock(ConfigLoaderInterface::class);
$config = SystemConfigurationFactory::create($loader, [
@@ -57,7 +58,7 @@ class TimesheetOverlappingValidatorTest extends ConstraintValidatorTestCase
{
$this->expectException(UnexpectedTypeException::class);
$this->validator->validate(new NotBlank(), new TimesheetOverlapping(['message' => 'myMessage']));
$this->validator->validate(new NotBlank(), new TimesheetOverlapping(['message' => 'myMessage'])); // @phpstan-ignore-line
}
public function testOverlappingDisallowedWithRecords()

View File

@@ -18,7 +18,7 @@ use App\Tests\Mocks\TrackingModeServiceFactory;
use App\Validator\Constraints\TimesheetOverlapping;
use App\Validator\Constraints\TimesheetRestart;
use App\Validator\Constraints\TimesheetRestartValidator;
use Symfony\Component\Security\Core\Security;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
@@ -26,15 +26,16 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\TimesheetRestart
* @covers \App\Validator\Constraints\TimesheetRestartValidator
* @extends ConstraintValidatorTestCase<TimesheetRestartValidator>
*/
class TimesheetRestartValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): TimesheetRestartValidator
{
return $this->createMyValidator(false, 'default');
}
protected function createMyValidator(bool $allowed, string $trackingMode)
protected function createMyValidator(bool $allowed, string $trackingMode): TimesheetRestartValidator
{
$auth = $this->createMock(Security::class);
$auth->method('getUser')->willReturn(new User());
@@ -56,7 +57,7 @@ class TimesheetRestartValidatorTest extends ConstraintValidatorTestCase
{
$this->expectException(UnexpectedTypeException::class);
$this->validator->validate(new NotBlank(), new TimesheetOverlapping(['message' => 'myMessage']));
$this->validator->validate(new NotBlank(), new TimesheetOverlapping(['message' => 'myMessage'])); // @phpstan-ignore-line
}
/**

View File

@@ -19,15 +19,16 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\Timesheet
* @covers \App\Validator\Constraints\TimesheetValidator
* @extends ConstraintValidatorTestCase<TimesheetValidator>
*/
class TimesheetValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): TimesheetValidator
{
return $this->createMyValidator();
}
protected function createMyValidator(bool $isGranted = true)
protected function createMyValidator(bool $isGranted = true): TimesheetValidator
{
return new TimesheetValidator([]);
}
@@ -43,6 +44,6 @@ class TimesheetValidatorTest extends ConstraintValidatorTestCase
{
$this->expectException(UnexpectedTypeException::class);
$this->validator->validate(new NotBlank(), new TimesheetConstraint(['message' => 'myMessage']));
$this->validator->validate(new NotBlank(), new TimesheetConstraint(['message' => 'myMessage'])); // @phpstan-ignore-line
}
}

View File

@@ -21,15 +21,16 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\TimesheetZeroDuration
* @covers \App\Validator\Constraints\TimesheetZeroDurationValidator
* @extends ConstraintValidatorTestCase<TimesheetZeroDurationValidator>
*/
class TimesheetZeroDurationValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): TimesheetZeroDurationValidator
{
return $this->createMyValidator(false);
}
protected function createMyValidator(bool $allowZeroDuration = false)
protected function createMyValidator(bool $allowZeroDuration = false): TimesheetZeroDurationValidator
{
$loader = $this->createMock(ConfigLoaderInterface::class);
$config = SystemConfigurationFactory::create($loader, [
@@ -54,7 +55,7 @@ class TimesheetZeroDurationValidatorTest extends ConstraintValidatorTestCase
{
$this->expectException(UnexpectedTypeException::class);
$this->validator->validate(new NotBlank(), new TimesheetZeroDuration(['message' => 'Duration cannot be zero.']));
$this->validator->validate(new NotBlank(), new TimesheetZeroDuration(['message' => 'Duration cannot be zero.'])); // @phpstan-ignore-line
}
private function prepareTimesheet()

View File

@@ -21,10 +21,11 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\User
* @covers \App\Validator\Constraints\UserValidator
* @extends ConstraintValidatorTestCase<UserValidator>
*/
class UserValidatorTest extends ConstraintValidatorTestCase
{
protected function createValidator()
protected function createValidator(): UserValidator
{
$userService = $this->createMock(UserService::class);
@@ -35,19 +36,19 @@ class UserValidatorTest extends ConstraintValidatorTestCase
{
$this->expectException(UnexpectedTypeException::class);
$this->validator->validate('foo', new NotBlank());
$this->validator->validate('foo', new NotBlank()); // @phpstan-ignore-line
}
public function testNullIsValid()
{
$this->validator->validate(null, new User(['message' => 'myMessage']));
$this->validator->validate(null, new User(['message' => 'myMessage'])); // @phpstan-ignore-line
$this->assertNoViolation();
}
public function testNonUserIsValid()
{
$this->validator->validate(new TestUserEntity(), new User(['message' => 'myMessage']));
$this->validator->validate(new TestUserEntity(), new User(['message' => 'myMessage'])); // @phpstan-ignore-line
$this->assertNoViolation();
}