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

@@ -110,7 +110,7 @@ class ApiDocControllerTest extends ControllerBaseTest
$this->assertArrayHasKey('security', $json);
$this->assertArrayHasKey('X-AUTH-USER', $json['security'][0]);
$this->assertArrayHasKey('X-AUTH-TOKEN', $json['security'][1]);
$this->assertArrayHasKey('X-AUTH-TOKEN', $json['security'][0]);
$this->assertArrayHasKey('components', $json);
$this->assertArrayHasKey('schemas', $json['components']);

View File

@@ -111,25 +111,45 @@ class ProjectControllerTest extends APIControllerBaseTest
$customer = $em->getRepository(Customer::class)->find(1);
$customer2 = (new Customer('first one'))->setVisible(false)->setCountry('de')->setTimezone('Europe/Berlin');
$customer2 = new Customer('first one');
$customer2->setVisible(false);
$customer2->setCountry('de');
$customer2->setTimezone('Europe/Berlin');
$em->persist($customer2);
$customer3 = (new Customer('second one'))->setCountry('at')->setTimezone('Europe/Vienna');
$customer3 = new Customer('second one');
$customer3->setCountry('at');
$customer3->setTimezone('Europe/Vienna');
$em->persist($customer3);
$project = (new Project())->setName('first')->setVisible(false)->setCustomer($customer2);
$project = new Project();
$project->setName('first');
$project->setVisible(false);
$project->setCustomer($customer2);
$em->persist($project);
$project = (new Project())->setName('second')->setVisible(false)->setCustomer($customer);
$project = new Project();
$project->setName('second');
$project->setVisible(false);
$project->setCustomer($customer);
$em->persist($project);
$project = (new Project())->setName('third')->setVisible(true)->setCustomer($customer2);
$project = new Project();
$project->setName('third');
$project->setVisible(true);
$project->setCustomer($customer2);
$em->persist($project);
$project = (new Project())->setName('fourth')->setVisible(true)->setCustomer($customer3);
$project = new Project();
$project->setName('fourth');
$project->setVisible(true);
$project->setCustomer($customer3);
$em->persist($project);
$project = (new Project())->setName('fifth')->setVisible(true)->setCustomer($customer);
$project = new Project();
$project->setName('fifth');
$project->setVisible(true);
$project->setCustomer($customer);
// add meta fields
$meta = new ProjectMeta();
@@ -227,25 +247,23 @@ class ProjectControllerTest extends APIControllerBaseTest
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$em = $this->getEntityManager();
$customer = (new Customer('first one'))
->setVisible(true)
->setCountry('de')
->setTimezone('Europe/Berlin')
;
$customer = new Customer('first one');
$customer->setVisible(true);
$customer->setCountry('de');
$customer->setTimezone('Europe/Berlin');
$em->persist($customer);
$orderDate = new \DateTime('2019-11-29 14:35:17', new \DateTimeZone('Pacific/Tongatapu'));
$startDate = new \DateTime('2020-01-07 18:19:20', new \DateTimeZone('Pacific/Tongatapu'));
$endDate = new \DateTime('2021-03-23 00:00:01', new \DateTimeZone('Pacific/Tongatapu'));
$project = (new Project())
->setName('first')
->setVisible(true)
->setCustomer($customer)
->setOrderDate($orderDate)
->setStart($startDate)
->setEnd($endDate)
;
$project = new Project();
$project->setName('first');
$project->setVisible(true);
$project->setCustomer($customer);
$project->setOrderDate($orderDate);
$project->setStart($startDate);
$project->setEnd($endDate);
$em->persist($project);
$em->flush();

View File

@@ -16,8 +16,8 @@ use JMS\Serializer\GraphNavigatorInterface;
use JMS\Serializer\JsonSerializationVisitor;
use JMS\Serializer\SerializationContext;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Contracts\Translation\TranslatorInterface;

View File

@@ -467,11 +467,19 @@ class TimesheetControllerTest extends APIControllerBaseTest
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$em = $this->getEntityManager();
$customer = (new Customer('foo-bar-1'))->setVisible(false)->setCountry('DE')->setTimezone('Europe/Berlin');
$customer = new Customer('foo-bar-1');
$customer->setVisible(false);
$customer->setCountry('DE');
$customer->setTimezone('Europe/Berlin');
$em->persist($customer);
$project = (new Project())->setName('foo-bar-2')->setVisible(true)->setCustomer($customer);
$project = new Project();
$project->setName('foo-bar-2');
$project->setVisible(true);
$project->setCustomer($customer);
$em->persist($project);
$activity = (new Activity())->setName('foo-bar-3')->setVisible(true);
$activity = new Activity();
$activity->setName('foo-bar-3');
$activity->setVisible(true);
$em->persist($activity);
$em->flush();
@@ -493,11 +501,19 @@ class TimesheetControllerTest extends APIControllerBaseTest
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$em = $this->getEntityManager();
$customer = (new Customer('foo-bar-1'))->setVisible(true)->setCountry('DE')->setTimezone('Europe/Berlin');
$customer = new Customer('foo-bar-1');
$customer->setVisible(true);
$customer->setCountry('DE');
$customer->setTimezone('Europe/Berlin');
$em->persist($customer);
$project = (new Project())->setName('foo-bar-2')->setVisible(true)->setCustomer($customer);
$project = new Project();
$project->setName('foo-bar-2');
$project->setVisible(true);
$project->setCustomer($customer);
$em->persist($project);
$activity = (new Activity())->setName('foo-bar-3')->setVisible(false);
$activity = new Activity();
$activity->setName('foo-bar-3');
$activity->setVisible(false);
$em->persist($activity);
$em->flush();
@@ -517,12 +533,17 @@ class TimesheetControllerTest extends APIControllerBaseTest
$client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);
$em = $this->getEntityManager();
$customer = (new Customer('foo-bar-1'))->setCountry('DE')->setTimezone('Europe/Berlin');
$customer = new Customer('foo-bar-1');
$customer->setCountry('DE');
$customer->setTimezone('Europe/Berlin');
$customer->setBillable(false);
$em->persist($customer);
$project = (new Project())->setName('foo-bar-2')->setCustomer($customer);
$project = new Project();
$project->setName('foo-bar-2');
$project->setCustomer($customer);
$em->persist($project);
$activity = (new Activity())->setName('foo-bar-3');
$activity = new Activity();
$activity->setName('foo-bar-3');
$em->persist($activity);
$em->flush();
@@ -547,12 +568,17 @@ class TimesheetControllerTest extends APIControllerBaseTest
$client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);
$em = $this->getEntityManager();
$customer = (new Customer('foo-bar-1'))->setCountry('DE')->setTimezone('Europe/Berlin');
$customer = new Customer('foo-bar-1');
$customer->setCountry('DE');
$customer->setTimezone('Europe/Berlin');
$customer->setBillable(false);
$em->persist($customer);
$project = (new Project())->setName('foo-bar-2')->setCustomer($customer);
$project = new Project();
$project->setName('foo-bar-2');
$project->setCustomer($customer);
$em->persist($project);
$activity = (new Activity())->setName('foo-bar-3');
$activity = new Activity();
$activity->setName('foo-bar-3');
$em->persist($activity);
$em->flush();

View File

@@ -18,11 +18,11 @@ use App\Tests\Mocks\Saml\SamlAuthFactoryFactory;
use App\Tests\Mocks\SystemConfigurationFactory;
use OneLogin\Saml2\Auth;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Core\Security;
/**
* @group integration

View File

@@ -0,0 +1,69 @@
<?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\DependencyInjection\Compiler;
use App\DependencyInjection\Compiler\ExportServiceCompilerPass;
use App\Export\Renderer\CsvRenderer;
use App\Export\Renderer\HtmlRenderer;
use App\Export\ServiceExport;
use App\Export\Timesheet\PDFRenderer;
use App\Export\Timesheet\XlsxRenderer;
use App\Export\TimesheetExportRepository;
use App\Kernel;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
/**
* @covers \App\DependencyInjection\Compiler\ExportServiceCompilerPass
*/
class ExportServiceCompilerPassTest extends TestCase
{
private function getContainer(): ContainerBuilder
{
$container = new ContainerBuilder();
$container->setParameter('kimai.export.documents', []); // TODO we could test that as well
$definition = new Definition(ServiceExport::class);
$container->setDefinition(ServiceExport::class, $definition);
$renderers = [CsvRenderer::class, HtmlRenderer::class];
foreach ($renderers as $renderer) {
$container->register($renderer)->addTag(Kernel::TAG_EXPORT_RENDERER);
}
$exporters = [PDFRenderer::class, XlsxRenderer::class];
foreach ($exporters as $exporter) {
$container->register($exporter)->addTag(Kernel::TAG_TIMESHEET_EXPORTER);
}
$repositories = [TimesheetExportRepository::class];
foreach ($repositories as $repository) {
$container->register($repository)->addTag(Kernel::TAG_EXPORT_REPOSITORY);
}
return $container;
}
public function testCallsAreAdded(): void
{
$container = $this->getContainer();
$sut = new ExportServiceCompilerPass();
$sut->process($container);
$definition = $container->findDefinition(ServiceExport::class);
$methods = $definition->getMethodCalls();
self::assertCount(5, $methods);
self::assertTrue($definition->hasMethodCall('addRenderer'));
self::assertTrue($definition->hasMethodCall('addTimesheetExporter'));
self::assertTrue($definition->hasMethodCall('addExportRepository'));
}
}

View File

@@ -0,0 +1,76 @@
<?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\DependencyInjection\Compiler;
use App\DependencyInjection\Compiler\InvoiceServiceCompilerPass;
use App\Invoice\Calculator\DefaultCalculator;
use App\Invoice\Calculator\ShortInvoiceCalculator;
use App\Invoice\Calculator\UserInvoiceCalculator;
use App\Invoice\NumberGenerator\ConfigurableNumberGenerator;
use App\Invoice\NumberGenerator\DateNumberGenerator;
use App\Invoice\Renderer\DocxRenderer;
use App\Invoice\ServiceInvoice;
use App\Kernel;
use App\Repository\TimesheetInvoiceItemRepository;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
/**
* @covers \App\DependencyInjection\Compiler\InvoiceServiceCompilerPass
*/
class InvoiceServiceCompilerPassTest extends TestCase
{
private function getContainer(): ContainerBuilder
{
$container = new ContainerBuilder();
$definition = new Definition(ServiceInvoice::class);
$container->setDefinition(ServiceInvoice::class, $definition);
$renderers = [DocxRenderer::class];
foreach ($renderers as $renderer) {
$container->register($renderer)->addTag(Kernel::TAG_INVOICE_RENDERER);
}
$numberGenerators = [DateNumberGenerator::class, ConfigurableNumberGenerator::class];
foreach ($numberGenerators as $numberGenerator) {
$container->register($numberGenerator)->addTag(Kernel::TAG_INVOICE_NUMBER_GENERATOR);
}
$calculators = [DefaultCalculator::class, UserInvoiceCalculator::class, ShortInvoiceCalculator::class];
foreach ($calculators as $calculator) {
$container->register($calculator)->addTag(Kernel::TAG_INVOICE_CALCULATOR);
}
$repositories = [TimesheetInvoiceItemRepository::class];
foreach ($repositories as $repository) {
$container->register($repository)->addTag(Kernel::TAG_INVOICE_REPOSITORY);
}
return $container;
}
public function testCallsAreAdded(): void
{
$container = $this->getContainer();
$sut = new InvoiceServiceCompilerPass();
$sut->process($container);
$definition = $container->findDefinition(ServiceInvoice::class);
$methods = $definition->getMethodCalls();
self::assertCount(7, $methods);
self::assertTrue($definition->hasMethodCall('addRenderer'));
self::assertTrue($definition->hasMethodCall('addNumberGenerator'));
self::assertTrue($definition->hasMethodCall('addCalculator'));
self::assertTrue($definition->hasMethodCall('addInvoiceItemRepository'));
}
}

View File

@@ -0,0 +1,65 @@
<?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\DependencyInjection\Compiler;
use App\DependencyInjection\Compiler\TwigContextCompilerPass;
use App\Export\ServiceExport;
use App\Twig\Configuration;
use App\Twig\Context;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
/**
* @covers \App\DependencyInjection\Compiler\TwigContextCompilerPass
*/
class TwigContextCompilerPassTest extends TestCase
{
private function getContainer(): ContainerBuilder
{
$container = new ContainerBuilder();
$container->setParameter('kimai.invoice.documents', []); // TODO we could test that as well
$container->setParameter('kimai.export.documents', []); // TODO we could test that as well
$definition = new Definition('twig');
$container->setDefinition('twig', $definition);
$definition = new Definition('twig.loader.native_filesystem');
$container->setDefinition('twig.loader.native_filesystem', $definition);
$definition = new Definition(ServiceExport::class);
$container->setDefinition(ServiceExport::class, $definition);
$definition = new Definition(Context::class);
$container->setDefinition(Context::class, $definition);
$definition = new Definition(Configuration::class);
$container->setDefinition(Configuration::class, $definition);
return $container;
}
public function testCallsAreAdded(): void
{
$container = $this->getContainer();
$sut = new TwigContextCompilerPass();
$sut->process($container);
$definition = $container->findDefinition('twig');
$methods = $definition->getMethodCalls();
self::assertCount(2, $methods);
self::assertTrue($definition->hasMethodCall('addGlobal'));
self::assertEquals('addGlobal', $methods[0][0]);
self::assertEquals('kimai_context', $methods[0][1][0]);
self::assertEquals('addGlobal', $methods[1][0]);
self::assertEquals('kimai_config', $methods[1][1][0]);
}
}

View File

@@ -0,0 +1,53 @@
<?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\DependencyInjection\Compiler;
use App\DependencyInjection\Compiler\WidgetCompilerPass;
use App\Kernel;
use App\Widget\Type\ActiveTimesheets;
use App\Widget\Type\ActiveUsersMonth;
use App\Widget\WidgetService;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
/**
* @covers \App\DependencyInjection\Compiler\WidgetCompilerPass
*/
class WidgetCompilerPassTest extends TestCase
{
private function getContainer(): ContainerBuilder
{
$container = new ContainerBuilder();
$definition = new Definition(WidgetService::class);
$container->setDefinition(WidgetService::class, $definition);
$widgets = [ActiveTimesheets::class, ActiveUsersMonth::class];
foreach ($widgets as $widget) {
$container->register($widget)->addTag(Kernel::TAG_WIDGET);
}
return $container;
}
public function testCallsAreAdded(): void
{
$container = $this->getContainer();
$sut = new WidgetCompilerPass();
$sut->process($container);
$definition = $container->findDefinition(WidgetService::class);
$methods = $definition->getMethodCalls();
self::assertCount(2, $methods);
self::assertTrue($definition->hasMethodCall('registerWidget'));
}
}

View File

@@ -65,7 +65,7 @@ class CustomerTest extends AbstractEntityTest
self::assertEquals('foo-bar', $sut->getName());
self::assertEquals('foo-bar', (string) $sut);
self::assertInstanceOf(Customer::class, $sut->setVisible(false));
$sut->setVisible(false);
self::assertFalse($sut->isVisible());
$sut->setVisible(false);
@@ -73,7 +73,7 @@ class CustomerTest extends AbstractEntityTest
$sut->setVisible(true);
self::assertTrue($sut->isVisible());
self::assertInstanceOf(Customer::class, $sut->setComment('hello world'));
$sut->setComment('hello world');
self::assertEquals('hello world', $sut->getComment());
self::assertFalse($sut->hasColor());
@@ -85,35 +85,38 @@ class CustomerTest extends AbstractEntityTest
self::assertNull($sut->getColor());
self::assertFalse($sut->hasColor());
self::assertInstanceOf(Customer::class, $sut->setCompany('test company'));
$sut->setCompany('test company');
self::assertEquals('test company', $sut->getCompany());
self::assertInstanceOf(Customer::class, $sut->setContact('test contact'));
$sut->setContact('test contact');
self::assertEquals('test contact', $sut->getContact());
self::assertInstanceOf(Customer::class, $sut->setPhone('0123456789'));
$sut->setPhone('0123456789');
self::assertEquals('0123456789', $sut->getPhone());
self::assertInstanceOf(Customer::class, $sut->setFax('asdfghjkl'));
$sut->setFax('asdfghjkl');
self::assertEquals('asdfghjkl', $sut->getFax());
self::assertInstanceOf(Customer::class, $sut->setMobile('76576534'));
$sut->setMobile('76576534');
self::assertEquals('76576534', $sut->getMobile());
self::assertInstanceOf(Customer::class, $sut->setEmail('test@example.com'));
$sut->setEmail('test@example.com');
self::assertEquals('test@example.com', $sut->getEmail());
self::assertInstanceOf(Customer::class, $sut->setHomepage('https://www.example.com'));
$sut->setHomepage('https://www.example.com');
self::assertEquals('https://www.example.com', $sut->getHomepage());
self::assertInstanceOf(Customer::class, $sut->setVatId('ID 1234567890'));
$sut->setVatId('ID 1234567890');
self::assertEquals('ID 1234567890', $sut->getVatId());
self::assertInstanceOf(Customer::class, $sut->setCountry(null));
$sut->setCountry(null);
self::assertNull($sut->getCountry());
self::assertInstanceOf(Customer::class, $sut->setCurrency('USD'));
$sut->setCurrency('USD');
self::assertEquals('USD', $sut->getCurrency());
$sut->setCurrency(null);
self::assertNull($sut->getCurrency());
}
public function testMetaFields()

View File

@@ -50,11 +50,9 @@ class TimesheetValidationTest extends KernelTestCase
$project->setCustomer(new Customer('foo'));
$entity = new Timesheet();
$entity
->setUser(new User())
->setProject($project)
->setBegin(new \DateTime())
;
$entity->setUser(new User());
$entity->setProject($project);
$entity->setBegin(new \DateTime());
$this->assertHasViolationForField($entity, 'activity');
}
@@ -62,11 +60,9 @@ class TimesheetValidationTest extends KernelTestCase
public function testValidationNeedsProject()
{
$entity = new Timesheet();
$entity
->setUser(new User())
->setActivity(new Activity())
->setBegin(new \DateTime())
;
$entity->setUser(new User());
$entity->setActivity(new Activity());
$entity->setBegin(new \DateTime());
$this->assertHasViolationForField($entity, 'project');
}
@@ -79,29 +75,30 @@ class TimesheetValidationTest extends KernelTestCase
$activity = (new Activity())->setName('hello-world')->setProject($project);
$entity = new Timesheet();
$entity
->setUser(new User())
->setActivity($activity)
->setProject($project2)
->setBegin(new \DateTime())
;
$entity->setUser(new User());
$entity->setActivity($activity);
$entity->setProject($project2);
$entity->setBegin(new \DateTime());
$this->assertHasViolationForField($entity, 'project');
}
public function testValidationCustomerInvisible()
{
$customer = (new Customer('foo'))->setVisible(false);
$project = (new Project())->setName('foo')->setCustomer($customer);
$activity = (new Activity())->setName('hello-world')->setProject($project);
$customer = new Customer('foo');
$customer->setVisible(false);
$project = new Project();
$project->setName('foo');
$project->setCustomer($customer);
$activity = new Activity();
$activity->setName('hello-world');
$activity->setProject($project);
$entity = new Timesheet();
$entity
->setUser(new User())
->setActivity($activity)
->setProject($project)
->setBegin(new \DateTime())
;
$entity->setUser(new User());
$entity->setActivity($activity);
$entity->setProject($project);
$entity->setBegin(new \DateTime());
$this->assertHasViolationForField($entity, 'customer');
}
@@ -109,13 +106,11 @@ class TimesheetValidationTest extends KernelTestCase
private function createStoppedTimesheet(Project $project, Activity $activity, ?int $id = null): Timesheet
{
$entity = new Timesheet();
$entity
->setUser(new User())
->setActivity($activity)
->setProject($project)
->setBegin(new \DateTime())
->setEnd(new \DateTime())
;
$entity->setUser(new User());
$entity->setActivity($activity);
$entity->setProject($project);
$entity->setBegin(new \DateTime());
$entity->setEnd(new \DateTime());
if ($id !== null) {
$o = new \ReflectionClass($entity);
@@ -130,9 +125,14 @@ class TimesheetValidationTest extends KernelTestCase
public function testValidationCustomerInvisibleDoesNotTriggerOnStoppedEntities()
{
$customer = (new Customer('foo'))->setVisible(false);
$project = (new Project())->setName('foo')->setCustomer($customer);
$activity = (new Activity())->setName('hello-world')->setProject($project);
$customer = new Customer('foo');
$customer->setVisible(false);
$project = new Project();
$project->setName('foo');
$project->setCustomer($customer);
$activity = new Activity();
$activity->setName('hello-world');
$activity->setProject($project);
$entity = $this->createStoppedTimesheet($project, $activity, 99);
@@ -141,9 +141,14 @@ class TimesheetValidationTest extends KernelTestCase
public function testValidationCustomerInvisibleDoesTriggerOnNewEntities()
{
$customer = (new Customer('foo'))->setVisible(false);
$project = (new Project())->setName('foo')->setCustomer($customer);
$activity = (new Activity())->setName('hello-world')->setProject($project);
$customer = new Customer('foo');
$customer->setVisible(false);
$project = new Project();
$project->setName('foo');
$project->setCustomer($customer);
$activity = new Activity();
$activity->setName('hello-world');
$activity->setProject($project);
$entity = $this->createStoppedTimesheet($project, $activity);
@@ -157,12 +162,10 @@ class TimesheetValidationTest extends KernelTestCase
$activity = (new Activity())->setName('hello-world')->setProject($project);
$entity = new Timesheet();
$entity
->setUser(new User())
->setActivity($activity)
->setProject($project)
->setBegin(new \DateTime())
;
$entity->setUser(new User());
$entity->setActivity($activity);
$entity->setProject($project);
$entity->setBegin(new \DateTime());
$this->assertHasViolationForField($entity, 'project');
}
@@ -196,12 +199,10 @@ class TimesheetValidationTest extends KernelTestCase
$activity = (new Activity())->setName('hello-world')->setProject($project)->setVisible(false);
$entity = new Timesheet();
$entity
->setUser(new User())
->setActivity($activity)
->setProject($project)
->setBegin(new \DateTime())
;
$entity->setUser(new User());
$entity->setActivity($activity);
$entity->setProject($project);
$entity->setBegin(new \DateTime());
$this->assertHasViolationForField($entity, 'activity');
}
@@ -209,8 +210,13 @@ class TimesheetValidationTest extends KernelTestCase
public function testValidationActivityInvisibleDoesNotTriggerOnStoppedEntities()
{
$customer = new Customer('foo');
$project = (new Project())->setName('foo')->setCustomer($customer);
$activity = (new Activity())->setName('hello-world')->setProject($project)->setVisible(false);
$project = new Project();
$project->setName('foo');
$project->setCustomer($customer);
$activity = new Activity();
$activity->setName('hello-world');
$activity->setProject($project);
$activity->setVisible(false);
$entity = $this->createStoppedTimesheet($project, $activity, 2);
@@ -220,8 +226,13 @@ class TimesheetValidationTest extends KernelTestCase
public function testValidationActivityInvisibleDoesTriggerOnNewEntities()
{
$customer = new Customer('foo');
$project = (new Project())->setName('foo')->setCustomer($customer);
$activity = (new Activity())->setName('hello-world')->setProject($project)->setVisible(false);
$project = new Project();
$project->setName('foo');
$project->setCustomer($customer);
$activity = new Activity();
$activity->setName('hello-world');
$activity->setProject($project);
$activity->setVisible(false);
$entity = $this->createStoppedTimesheet($project, $activity);

View File

@@ -30,10 +30,10 @@ use App\Export\TimesheetExportInterface;
use App\Repository\Query\TimesheetQuery;
use App\Twig\LocaleFormatExtensions;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
abstract class AbstractRendererTest extends KernelTestCase

View File

@@ -29,10 +29,10 @@ use App\Export\TimesheetExportInterface;
use App\Repository\Query\TimesheetQuery;
use App\Twig\LocaleFormatExtensions;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
abstract class AbstractRendererTest extends KernelTestCase

View File

@@ -12,9 +12,9 @@ namespace App\Tests\Form\Type;
use App\Entity\Timesheet;
use App\Entity\User;
use App\Form\Type\QuickEntryTimesheetType;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Form\PreloadedExtension;
use Symfony\Component\Form\Test\TypeTestCase;
use Symfony\Component\Security\Core\Security;
/**
* @covers \App\Form\Type\QuickEntryTimesheetType

View File

@@ -15,8 +15,8 @@ use App\Entity\User;
use App\Entity\UserPreference;
use App\Twig\LocaleFormatExtensions;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Intl\Util\IntlTestHelper;
use Symfony\Component\Security\Core\Security;
use Twig\TwigFilter;
use Twig\TwigFunction;
use Twig\TwigTest;

View File

@@ -14,10 +14,10 @@ use App\Twig\Runtime\WidgetExtension;
use App\Widget\Type\More;
use App\Widget\WidgetService;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Security;
use Twig\Environment;
/**

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();
}

View File

@@ -10982,11 +10982,6 @@ parameters:
count: 6
path: Utils/StringHelperTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\ColorChoicesValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/ColorChoicesValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\ColorChoicesValidatorTest\\:\\:getInvalidColors\\(\\) has no return type specified\\.$#"
count: 1
@@ -11012,11 +11007,6 @@ parameters:
count: 1
path: Validator/Constraints/ColorChoicesValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\DateTimeFormatValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/DateTimeFormatValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\DateTimeFormatValidatorTest\\:\\:getInvalidData\\(\\) has no return type specified\\.$#"
count: 1
@@ -11042,11 +11032,6 @@ parameters:
count: 1
path: Validator/Constraints/DateTimeFormatValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\DurationValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/DurationValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\DurationValidatorTest\\:\\:getInvalidData\\(\\) has no return type specified\\.$#"
count: 1
@@ -11082,11 +11067,6 @@ parameters:
count: 1
path: Validator/Constraints/DurationValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\HexColorValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/HexColorValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\HexColorValidatorTest\\:\\:getInvalidColors\\(\\) has no return type specified\\.$#"
count: 1
@@ -11117,11 +11097,6 @@ parameters:
count: 1
path: Validator/Constraints/HexColorValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\ProjectValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/ProjectValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\ProjectValidatorTest\\:\\:testConstraintIsInvalid\\(\\) has no return type specified\\.$#"
count: 1
@@ -11137,11 +11112,6 @@ parameters:
count: 1
path: Validator/Constraints/ProjectValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\QuickEntryModelValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/QuickEntryModelValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\QuickEntryModelValidatorTest\\:\\:testConstraintIsInvalid\\(\\) has no return type specified\\.$#"
count: 1
@@ -11177,11 +11147,6 @@ parameters:
count: 1
path: Validator/Constraints/QuickEntryModelValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\QuickEntryTimesheetValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/QuickEntryTimesheetValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\QuickEntryTimesheetValidatorTest\\:\\:testConstraintIsInvalid\\(\\) has no return type specified\\.$#"
count: 1
@@ -11202,11 +11167,6 @@ parameters:
count: 1
path: Validator/Constraints/RoleValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\RoleValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/RoleValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\RoleValidatorTest\\:\\:getInvalidRoles\\(\\) has no return type specified\\.$#"
count: 1
@@ -11237,11 +11197,6 @@ parameters:
count: 1
path: Validator/Constraints/RoleValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TeamValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TeamValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TeamValidatorTest\\:\\:testConstraintIsInvalid\\(\\) has no return type specified\\.$#"
count: 1
@@ -11252,11 +11207,6 @@ parameters:
count: 1
path: Validator/Constraints/TeamValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimeFormatValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimeFormatValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimeFormatValidatorTest\\:\\:getInvalidTimes\\(\\) has no return type specified\\.$#"
count: 1
@@ -11292,16 +11242,6 @@ parameters:
count: 1
path: Validator/Constraints/TimesheetBasicValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetBasicValidatorTest\\:\\:createMyValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetBasicValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetBasicValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetBasicValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetBasicValidatorTest\\:\\:getProjectStartEndTestData\\(\\) has no return type specified\\.$#"
count: 1
@@ -11357,16 +11297,6 @@ parameters:
count: 1
path: Validator/Constraints/TimesheetBasicValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetBudgetUsedValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetBudgetUsedValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetBudgetUsedValidatorTest\\:\\:createValidator\\(\\) has parameter \\$rawData with no value type specified in iterable type array\\.$#"
count: 1
path: Validator/Constraints/TimesheetBudgetUsedValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetBudgetUsedValidatorTest\\:\\:getViolationTestData\\(\\) has no return type specified\\.$#"
count: 1
@@ -11422,16 +11352,6 @@ parameters:
count: 1
path: Validator/Constraints/TimesheetBudgetUsedValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetExportedValidatorTest\\:\\:createMyValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetExportedValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetExportedValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetExportedValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetExportedValidatorTest\\:\\:testConstraintIsInvalid\\(\\) has no return type specified\\.$#"
count: 1
@@ -11467,16 +11387,6 @@ parameters:
count: 1
path: Validator/Constraints/TimesheetExportedValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetFutureTimesValidatorTest\\:\\:createMyValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetFutureTimesValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetFutureTimesValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetFutureTimesValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetFutureTimesValidatorTest\\:\\:testConstraintIsInvalid\\(\\) has no return type specified\\.$#"
count: 1
@@ -11497,16 +11407,6 @@ parameters:
count: 1
path: Validator/Constraints/TimesheetFutureTimesValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetLockdownValidatorTest\\:\\:createMyValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetLockdownValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetLockdownValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetLockdownValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetLockdownValidatorTest\\:\\:getConfigTestData\\(\\) has no return type specified\\.$#"
count: 1
@@ -11557,16 +11457,6 @@ parameters:
count: 1
path: Validator/Constraints/TimesheetLockdownValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetLongRunningValidatorTest\\:\\:createMyValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetLongRunningValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetLongRunningValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetLongRunningValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetLongRunningValidatorTest\\:\\:testConstraintIsInvalid\\(\\) has no return type specified\\.$#"
count: 1
@@ -11612,16 +11502,6 @@ parameters:
count: 1
path: Validator/Constraints/TimesheetLongRunningValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetMultiUpdateValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetMultiUpdateValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetMultiUpdateValidatorTest\\:\\:createValidator\\(\\) has parameter \\$isGranted with no type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetMultiUpdateValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetMultiUpdateValidatorTest\\:\\:testActivityWithoutProject\\(\\) has no return type specified\\.$#"
count: 1
@@ -11652,16 +11532,6 @@ parameters:
count: 1
path: Validator/Constraints/TimesheetMultiUpdateValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetMultiUserValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetMultiUserValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetMultiUserValidatorTest\\:\\:createValidator\\(\\) has parameter \\$isGranted with no type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetMultiUserValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetMultiUserValidatorTest\\:\\:testConstraintIsInvalid\\(\\) has no return type specified\\.$#"
count: 1
@@ -11672,16 +11542,6 @@ parameters:
count: 1
path: Validator/Constraints/TimesheetMultiUserValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetOverlappingValidatorTest\\:\\:createMyValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetOverlappingValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetOverlappingValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetOverlappingValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetOverlappingValidatorTest\\:\\:testConstraintIsInvalid\\(\\) has no return type specified\\.$#"
count: 1
@@ -11712,16 +11572,6 @@ parameters:
count: 1
path: Validator/Constraints/TimesheetOverlappingValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetRestartValidatorTest\\:\\:createMyValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetRestartValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetRestartValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetRestartValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetRestartValidatorTest\\:\\:getTestData\\(\\) has no return type specified\\.$#"
count: 1
@@ -11742,16 +11592,6 @@ parameters:
count: 1
path: Validator/Constraints/TimesheetRestartValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetValidatorTest\\:\\:createMyValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetValidatorTest\\:\\:testConstraintIsInvalid\\(\\) has no return type specified\\.$#"
count: 1
@@ -11762,16 +11602,6 @@ parameters:
count: 1
path: Validator/Constraints/TimesheetValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetZeroDurationValidatorTest\\:\\:createMyValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetZeroDurationValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetZeroDurationValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/TimesheetZeroDurationValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\TimesheetZeroDurationValidatorTest\\:\\:prepareTimesheet\\(\\) has no return type specified\\.$#"
count: 1
@@ -11797,11 +11627,6 @@ parameters:
count: 1
path: Validator/Constraints/TimesheetZeroDurationValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\UserValidatorTest\\:\\:createValidator\\(\\) has no return type specified\\.$#"
count: 1
path: Validator/Constraints/UserValidatorTest.php
-
message: "#^Method App\\\\Tests\\\\Validator\\\\Constraints\\\\UserValidatorTest\\:\\:testConstraintIsInvalid\\(\\) has no return type specified\\.$#"
count: 1