Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)

This commit is contained in:
Kevin Papst
2022-12-31 21:19:55 +01:00
committed by GitHub
parent 95e06746bd
commit 90a0fd8a22
2164 changed files with 83700 additions and 86426 deletions

View File

@@ -9,12 +9,11 @@
namespace App\Tests\Invoice\Renderer;
use App\Configuration\LanguageFormattings;
use App\Configuration\LocaleService;
use App\Entity\Activity;
use App\Entity\ActivityMeta;
use App\Entity\Customer;
use App\Entity\CustomerMeta;
use App\Entity\InvoiceDocument;
use App\Entity\InvoiceTemplate;
use App\Entity\Project;
use App\Entity\ProjectMeta;
@@ -28,25 +27,20 @@ use App\Invoice\InvoiceFormatter;
use App\Invoice\InvoiceModel;
use App\Invoice\NumberGenerator\DateNumberGenerator;
use App\Invoice\Renderer\AbstractRenderer;
use App\Model\InvoiceDocument;
use App\Repository\InvoiceRepository;
use App\Repository\Query\InvoiceQuery;
use App\Tests\Mocks\InvoiceModelFactoryFactory;
use Doctrine\Common\Collections\ArrayCollection;
trait RendererTestTrait
{
/**
* @return string
*/
protected function getInvoiceTemplatePath()
protected function getInvoiceTemplatePath(): string
{
return __DIR__ . '/../../../templates/invoice/renderer/';
}
/**
* @param string $filename
* @return InvoiceDocument
*/
protected function getInvoiceDocument(string $filename, bool $testOnly = false)
protected function getInvoiceDocument(string $filename, bool $testOnly = false): InvoiceDocument
{
if (!$testOnly) {
return new InvoiceDocument(
@@ -59,11 +53,7 @@ trait RendererTestTrait
);
}
/**
* @param string $classname
* @return AbstractRenderer
*/
protected function getAbstractRenderer(string $classname)
protected function getAbstractRenderer(string $classname): AbstractRenderer
{
return new $classname();
}
@@ -72,13 +62,13 @@ trait RendererTestTrait
{
$languages = [
'en' => [
'date' => 'Y.m.d',
'duration' => '%h:%m h',
'date' => 'yy.MM.dd',
'time' => 'H:i',
'rtl' => false,
]
];
$formattings = new LanguageFormattings($languages);
$formattings = new LocaleService($languages);
return new DefaultInvoiceFormatter($formattings, 'en');
}
@@ -86,15 +76,14 @@ trait RendererTestTrait
protected function getInvoiceModel(): InvoiceModel
{
$user = new User();
$user->setUsername('one-user');
$user->setUserIdentifier('one-user');
$user->setTitle('user title');
$user->setAlias('genious alias');
$user->setEmail('fantastic@four');
$user->addPreference((new UserPreference())->setName('kitty')->setValue('kat'));
$user->addPreference((new UserPreference())->setName('hello')->setValue('world'));
$user->addPreference(new UserPreference('kitty', 'kat'));
$user->addPreference(new UserPreference('hello', 'world'));
$customer = new Customer();
$customer->setName('customer,with/special#name');
$customer = new Customer('customer,with/special#name');
$customer->setAddress('Foo' . PHP_EOL . 'Street' . PHP_EOL . '1111 City');
$customer->setCurrency('EUR');
$customer->setMetaField((new CustomerMeta())->setName('foo-customer')->setValue('bar-customer')->setIsVisible(true));
@@ -104,35 +93,57 @@ trait RendererTestTrait
$template->setVat(19);
$template->setLanguage('en');
$project = new Project();
$project->setName('project name');
$project->setCustomer($customer);
$project->setMetaField((new ProjectMeta())->setName('foo-project')->setValue('bar-project')->setIsVisible(true));
$pMeta = new ProjectMeta();
$pMeta->setName('foo-project')->setValue('bar-project')->setIsVisible(true);
$project = $this->createMock(Project::class);
$project->method('getId')->willReturn(0);
$project->method('getName')->willReturn('project name');
$project->method('getCustomer')->willReturn($customer);
$project->method('getMetaFields')->willReturn(new ArrayCollection([$pMeta]));
$project->method('getVisibleMetaFields')->willReturn([$pMeta]);
$activity = new Activity();
$activity->setName('activity description');
$activity->setProject($project);
$activity->setMetaField((new ActivityMeta())->setName('foo-activity')->setValue('bar-activity')->setIsVisible(true));
$aMeta = new ActivityMeta();
$aMeta->setName('foo-activity');
$aMeta->setValue('bar-activity');
$aMeta->setIsVisible(true);
$activity = $this->createMock(Activity::class);
$activity->method('getId')->willReturn(0);
$activity->method('getName')->willReturn('activity description');
$activity->method('getProject')->willReturn($project);
$activity->method('getMetaFields')->willReturn(new ArrayCollection([$aMeta]));
$activity->method('getVisibleMetaFields')->willReturn([$aMeta]);
$project2 = new Project();
$project2->setName('project 2 name');
$project2->setCustomer($customer);
$project2->setMetaField((new ProjectMeta())->setName('foo-project')->setValue('bar-project2')->setIsVisible(true));
$pMeta2 = new ProjectMeta();
$pMeta2->setName('foo-project')->setValue('bar-project2')->setIsVisible(true);
$project2 = $this->createMock(Project::class);
$project2->method('getId')->willReturn(1);
$project2->method('getName')->willReturn('project 2 name');
$project2->method('getCustomer')->willReturn($customer);
$project2->method('getMetaFields')->willReturn(new ArrayCollection([$pMeta2]));
$project2->method('getVisibleMetaFields')->willReturn([$pMeta2]);
$activity2 = new Activity();
$activity2->setName('activity 1 description');
$activity2->setProject($project2);
$activity2->setMetaField((new ActivityMeta())->setName('foo-activity')->setValue('bar-activity2')->setIsVisible(true));
$aMeta2 = new ActivityMeta();
$aMeta2->setName('foo-activity');
$aMeta2->setValue('bar-activity2');
$aMeta2->setIsVisible(true);
$activity2 = $this->createMock(Activity::class);
$activity2->method('getId')->willReturn(1);
$activity2->method('getName')->willReturn('activity 1 description');
$activity2->method('getProject')->willReturn($project2);
$activity2->method('getMetaFields')->willReturn(new ArrayCollection([$aMeta2]));
$activity2->method('getVisibleMetaFields')->willReturn([$aMeta2]);
$userMethods = ['getId', 'getPreferenceValue', 'getUsername'];
$userMethods = ['getId', 'getPreferenceValue', 'getUsername', 'getUserIdentifier'];
$user1 = $this->getMockBuilder(User::class)->onlyMethods($userMethods)->disableOriginalConstructor()->getMock();
$user1->method('getId')->willReturn(1);
$user1->method('getPreferenceValue')->willReturn('50');
$user1->method('getUsername')->willReturn('foo-bar');
$user1->method('getUserIdentifier')->willReturn('foo-bar');
$user2 = $this->getMockBuilder(User::class)->onlyMethods($userMethods)->disableOriginalConstructor()->getMock();
$user2->method('getId')->willReturn(2);
$user2->method('getUsername')->willReturn('hello-world');
$user2->method('getUserIdentifier')->willReturn('hello-world');
$timesheet = new Timesheet();
$timesheet
@@ -191,15 +202,18 @@ trait RendererTestTrait
->setMetaField((new TimesheetMeta())->setName('foo-timesheet3')->setValue('bluuuub')->setIsVisible(true))
;
$userKevin = new User();
$userKevin->setUserIdentifier('kevin');
$timesheet5 = new Timesheet();
$timesheet5
->setDuration(400)
->setFixedRate(84)
->setUser((new User())->setUsername('kevin'))
->setUser($userKevin)
->setActivity($activity)
->setProject($project)
->setBegin(new \DateTime('2021-03-12 07:13:00'))
->setEnd(new \DateTime('2021-03-12 07:17:40'))
->setBegin(new \DateTime('2021-03-12 12:13:00'))
->setEnd(new \DateTime('2021-03-12 12:17:40'))
->setDescription(
"foo\n" .
"foo\r\n" .
@@ -252,21 +266,21 @@ trait RendererTestTrait
protected function getInvoiceModelOneEntry(): InvoiceModel
{
$user = new User();
$user->setUsername('one-user');
$user->setUserIdentifier('one-user');
$user->setTitle('user title');
$user->setAlias('genious alias');
$user->setEmail('fantastic@four');
$user->addPreference((new UserPreference())->setName('kitty')->setValue('kat'));
$user->addPreference((new UserPreference())->setName('hello')->setValue('world'));
$user->addPreference(new UserPreference('kitty', 'kat'));
$user->addPreference(new UserPreference('hello', 'world'));
$customer = new Customer();
$customer->setName('customer,with/special#name');
$customer = new Customer('customer,with/special#name');
$customer->setCurrency('USD');
$customer->setMetaField((new CustomerMeta())->setName('foo-customer')->setValue('bar-customer')->setIsVisible(true));
$template = new InvoiceTemplate();
$template->setTitle('a test invoice template title');
$template->setVat(19);
$template->setLanguage('it');
$project = new Project();
$project->setName('project name');
@@ -278,11 +292,11 @@ trait RendererTestTrait
$activity->setProject($project);
$activity->setMetaField((new ActivityMeta())->setName('foo-activity')->setValue('bar-activity')->setIsVisible(true));
$userMethods = ['getId', 'getPreferenceValue', 'getUsername'];
$user1 = $this->getMockBuilder(User::class)->onlyMethods($userMethods)->disableOriginalConstructor()->getMock();
$user1 = $this->createMock(User::class);
$user1->method('getId')->willReturn(1);
$user1->method('getPreferenceValue')->willReturn('50');
$user1->method('getUsername')->willReturn('foo-bar');
$user1->method('getUserIdentifier')->willReturn('foo-bar');
$timesheet = new Timesheet();
$timesheet
@@ -299,6 +313,7 @@ trait RendererTestTrait
$query = new InvoiceQuery();
$query->addActivity($activity);
$query->addProject($project);
$query->setBegin(new \DateTime());
$query->setEnd(new \DateTime());