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

@@ -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'));
}
}