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

@@ -42,17 +42,17 @@ class BillableCalculatorTest extends TestCase
}
$timesheet->setBillable($billable);
$timesheet->setBillableMode($mode);
$sut->calculate($timesheet);
$sut->calculate($timesheet, []);
self::assertEquals($mode, $timesheet->getBillableMode());
self::assertEquals($expected, $timesheet->isBillable());
}
public function getTestData()
{
$customerYes = new Customer();
$customerYes = new Customer('foo');
$customerYes->setBillable(true);
$customerNo = new Customer();
$customerNo = new Customer('foo');
$customerNo->setBillable(false);
$projectYes = new Project();

View File

@@ -27,7 +27,7 @@ class DurationCalculatorTest extends TestCase
$this->assertEquals(0, $record->getDuration());
$sut = new DurationCalculator((new RoundingServiceFactory($this))->create());
$sut->calculate($record);
$sut->calculate($record, []);
$this->assertEquals(0, $record->getDuration());
}
@@ -42,7 +42,7 @@ class DurationCalculatorTest extends TestCase
$this->assertEquals(0, $record->getDuration());
$sut = new DurationCalculator((new RoundingServiceFactory($this))->create($rules));
$sut->calculate($record);
$sut->calculate($record, []);
$this->assertEquals($expectedDuration, $record->getDuration());
}
@@ -195,8 +195,8 @@ class DurationCalculatorTest extends TestCase
'mode' => 'default',
],
],
(clone $start)->setTime(12, 27, 00), // no diff, to test ...
(clone $start)->setTime(12, 27, 00), // ... that no rounding is applied
(clone $start)->setTime(12, 27, 0), // no diff, to test ...
(clone $start)->setTime(12, 27, 0), // ... that no rounding is applied
0
],
[

View File

@@ -48,7 +48,7 @@ class RateCalculatorTest extends TestCase
$record->setUser($this->getTestUser());
$sut = new RateCalculator(new RateService([], $this->getRateRepositoryMock()));
$sut->calculate($record);
$sut->calculate($record, []);
$this->assertEquals(50, $record->getRate());
}
@@ -64,7 +64,7 @@ class RateCalculatorTest extends TestCase
$record->setUser($this->getTestUser());
$sut = new RateCalculator(new RateService([], $this->getRateRepositoryMock()));
$sut->calculate($record);
$sut->calculate($record, []);
$this->assertEquals(10, $record->getRate());
}
@@ -123,7 +123,7 @@ class RateCalculatorTest extends TestCase
$customerInternal,
$customerIsFixed
) {
$customer = new Customer();
$customer = new Customer('foo');
$project = new Project();
$project->setCustomer($customer);
@@ -175,7 +175,7 @@ class RateCalculatorTest extends TestCase
}
$sut = new RateCalculator(new RateService([], $this->getRateRepositoryMock($rates)));
$sut->calculate($timesheet);
$sut->calculate($timesheet, []);
$this->assertEquals($expectedRate, $timesheet->getRate());
$this->assertEquals($expectedInternalRate, $timesheet->getInternalRate());
}
@@ -184,13 +184,8 @@ class RateCalculatorTest extends TestCase
{
$user = new User();
$pref = new UserPreference();
$pref->setName(UserPreference::HOURLY_RATE);
$pref->setValue($rate);
$prefInt = new UserPreference();
$prefInt->setName(UserPreference::INTERNAL_RATE);
$prefInt->setValue($internalRate);
$pref = new UserPreference(UserPreference::HOURLY_RATE, $rate);
$prefInt = new UserPreference(UserPreference::INTERNAL_RATE, $internalRate);
$user->setPreferences([$pref, $prefInt]);
@@ -209,7 +204,7 @@ class RateCalculatorTest extends TestCase
$this->assertEquals(0, $record->getRate());
$sut = new RateCalculator(new RateService([], $this->getRateRepositoryMock()));
$sut->calculate($record);
$sut->calculate($record, []);
$this->assertEquals(0, $record->getRate());
}
@@ -235,7 +230,7 @@ class RateCalculatorTest extends TestCase
$record->setEnd($end);
$sut = new RateCalculator(new RateService($rules, $this->getRateRepositoryMock()));
$sut->calculate($record);
$sut->calculate($record, []);
$this->assertEquals($expectedRate, $record->getRate());
}

View File

@@ -0,0 +1,56 @@
<?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\Timesheet\Calculator;
use App\Entity\Project;
use App\Entity\Timesheet;
use App\Entity\User;
use App\Entity\UserPreference;
use App\Timesheet\Calculator\RateResetCalculator;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Timesheet\Calculator\RateResetCalculator
*/
class RateResetCalculatorTest extends TestCase
{
public function testWithReset(): void
{
$record = new Timesheet();
$record->setRate(999.99);
$record->setHourlyRate(100);
$record->setFixedRate(123.45);
$record->setInternalRate(98.76);
$record->setBillableMode(Timesheet::BILLABLE_NO);
$user = new User();
$user->setPreferences([
new UserPreference(UserPreference::HOURLY_RATE, 75),
new UserPreference(UserPreference::INTERNAL_RATE, 25)
]);
$record->setUser($user);
self::assertEquals(999.99, $record->getRate());
self::assertEquals(100, $record->getHourlyRate());
self::assertEquals(123.45, $record->getFixedRate());
self::assertEquals(98.76, $record->getInternalRate());
self::assertEquals(Timesheet::BILLABLE_NO, $record->getBillableMode());
$sut = new RateResetCalculator();
// 0 = before, 1 = after
$sut->calculate($record, ['project' => [0 => new Project(), 1 => new Project()]]);
self::assertEquals(0.00, $record->getRate());
self::assertNull($record->getHourlyRate());
self::assertNull($record->getFixedRate());
self::assertNull($record->getInternalRate());
self::assertEquals(Timesheet::BILLABLE_AUTOMATIC, $record->getBillableMode());
}
}