* fix phpdoc
* fix invoice export field order
* prevent empty migration warning
* do not trigger export validation on new timesheets
* update license year
* remove trailing comma in function call for php compatibility
* add new composer plugin config
* bump phpunit schema version
This commit is contained in:
Kevin Papst
2022-01-20 17:10:56 +01:00
committed by GitHub
parent 40242b7dcc
commit fd4cbb43c1
10 changed files with 37 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2017-2019 Kevin Papst @ https://www.kevinpapst.de
Copyright (c) 2017-2022 Kevin Papst @ https://www.kevinpapst.de
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -107,7 +107,11 @@
"preferred-install": {
"*": "dist"
},
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": true,
"symfony/flex": true
}
},
"autoload": {
"psr-4": {

View File

@@ -1,12 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
>
bootstrap="tests/bootstrap.php">
<php>
<ini name="error_reporting" value="-1" />
<ini name="max_execution_time" value="-1" />
@@ -64,9 +61,8 @@
</filter>
<!--
begins a database transaction before every testcase and rolls it back after the test finished, so
tests can manipulate the database without affecting other tests
@see https://github.com/dmaicher/doctrine-test-bundle
wrap tests inside database transactions, so tests can safely manipulate contents without
affecting other tests. @see https://github.com/dmaicher/doctrine-test-bundle
-->
<extensions>
<extension class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" />

View File

@@ -286,7 +286,7 @@ class TranslationCommand extends Command
$id,
$values['resname'],
$values['source'],
$values['target'],
$values['target']
);
}

View File

@@ -325,7 +325,7 @@ class Activity implements EntityWithMetaFields, EntityWithBudget
$currentMeta = $this->meta;
$this->meta = new ArrayCollection();
/** @var ProjectMeta $meta */
/** @var ActivityMeta $meta */
foreach ($currentMeta as $meta) {
$newMeta = clone $meta;
$newMeta->setEntity($this);

View File

@@ -595,7 +595,7 @@ class Customer implements EntityWithMetaFields, EntityWithBudget
$currentMeta = $this->meta;
$this->meta = new ArrayCollection();
/** @var ProjectMeta $meta */
/** @var CustomerMeta $meta */
foreach ($currentMeta as $meta) {
$newMeta = clone $meta;
$newMeta->setEntity($this);

View File

@@ -29,7 +29,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @UniqueEntity("invoiceNumber")
* @UniqueEntity("invoiceFilename")
*
* @Exporter\Order({"id", "createdAt", "invoiceNumber", "status", "customer", "subtotal", "total", "tax", "currency", "vat", "dueDays", "dueDate", "paymentDate", "user", "invoiceFilename", "comment"})
* @Exporter\Order({"id", "createdAt", "invoiceNumber", "status", "customer", "subtotal", "total", "tax", "currency", "vat", "dueDays", "dueDate", "paymentDate", "user", "invoiceFilename", "customerNumber", "comment"})
* @Exporter\Expose("customer", label="label.customer", exp="object.getCustomer() === null ? null : object.getCustomer().getName()")
* @Exporter\Expose("customerNumber", label="label.number", exp="object.getCustomer() === null ? null : object.getCustomer().getNumber()")
* @Exporter\Expose("dueDate", label="invoice.due_days", type="datetime", exp="object.getDueDate() === null ? null : object.getDueDate()")

View File

@@ -38,5 +38,7 @@ final class Version20211008092010 extends AbstractMigration
$projects = $schema->getTable('kimai2_projects');
$column = $projects->getColumn('order_number');
$column->setOptions(['length' => 20]);
$this->preventEmptyMigrationWarning();
}
}

View File

@@ -38,6 +38,10 @@ final class TimesheetExportedValidator extends ConstraintValidator
throw new UnexpectedTypeException($timesheet, TimesheetEntity::class);
}
if ($timesheet->getId() === null) {
return;
}
if (!$timesheet->isExported()) {
return;
}

View File

@@ -66,8 +66,9 @@ class TimesheetExportedValidatorTest extends ConstraintValidatorTestCase
$this->validator = $this->createMyValidator(false);
$this->validator->initialize($this->context);
$timesheet = new Timesheet();
$timesheet->setExported(true);
$timesheet = $this->createMock(Timesheet::class);
$timesheet->method('isExported')->willReturn(true);
$timesheet->method('getId')->willReturn(1);
$this->validator->validate($timesheet, new TimesheetExported());
@@ -77,6 +78,20 @@ class TimesheetExportedValidatorTest extends ConstraintValidatorTestCase
->assertRaised();
}
public function testNotTriggersOnNewTimesheet()
{
$this->validator = $this->createMyValidator(false);
$this->validator->initialize($this->context);
$timesheet = $this->createMock(Timesheet::class);
$timesheet->method('isExported')->willReturn(true);
$timesheet->method('getId')->willReturn(null);
$this->validator->validate($timesheet, new TimesheetExported());
$this->assertNoViolation();
}
public function testDoesNotTriggerWithPermission()
{
$this->validator = $this->createMyValidator(true);