rounding rules via admin screen, round begin when starting record (#1229)

This commit is contained in:
Kevin Papst
2019-11-10 13:57:05 +01:00
committed by GitHub
parent fa1c79e15c
commit c6c4098759
47 changed files with 1100 additions and 185 deletions

View File

@@ -10,7 +10,9 @@
namespace App\Tests\Timesheet\TrackingMode;
use App\Configuration\TimesheetConfiguration;
use App\Entity\Timesheet;
use App\Tests\Configuration\TestConfigLoader;
use App\Tests\Mocks\RoundingServiceFactory;
use App\Tests\Mocks\Security\UserDateTimeFactoryFactory;
use App\Timesheet\TrackingMode\DefaultMode;
@@ -19,6 +21,12 @@ use App\Timesheet\TrackingMode\DefaultMode;
*/
class DefaultModeTest extends AbstractTrackingModeTest
{
protected function assertDefaultBegin(Timesheet $timesheet)
{
self::assertNotNull($timesheet->getBegin());
self::assertInstanceOf(\DateTime::class, $timesheet->getBegin());
}
/**
* @return DefaultMode
*/
@@ -28,7 +36,7 @@ class DefaultModeTest extends AbstractTrackingModeTest
$dateTime = (new UserDateTimeFactoryFactory($this))->create();
$configuration = new TimesheetConfiguration($loader, ['default_begin' => '13:47']);
return new DefaultMode($dateTime, $configuration);
return new DefaultMode($dateTime, $configuration, (new RoundingServiceFactory($this))->create());
}
public function testDefaultValues()

View File

@@ -10,6 +10,7 @@
namespace App\Tests\Timesheet\TrackingMode;
use App\Entity\Timesheet;
use App\Tests\Mocks\Security\UserDateTimeFactoryFactory;
use App\Timesheet\TrackingMode\PunchInOutMode;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
@@ -21,7 +22,8 @@ class PunchInOutModeTest extends TestCase
{
public function testDefaultValues()
{
$sut = new PunchInOutMode();
$dateTime = (new UserDateTimeFactoryFactory($this))->create();
$sut = new PunchInOutMode($dateTime);
self::assertFalse($sut->canEditBegin());
self::assertFalse($sut->canEditEnd());
@@ -33,13 +35,25 @@ class PunchInOutModeTest extends TestCase
public function testCreate()
{
$startingTime = new \DateTime('22:54');
$timesheet = new Timesheet();
$timesheet->setBegin(new \DateTime('22:54'));
$timesheet->setBegin($startingTime);
$request = new Request();
$timesheetNew = clone $timesheet;
$sut = new PunchInOutMode();
$dateTime = (new UserDateTimeFactoryFactory($this))->create();
$sut = new PunchInOutMode($dateTime);
$sut->create($timesheet, $request);
self::assertEquals($timesheet, $timesheetNew);
self::assertEquals($timesheet->getBegin(), $startingTime);
}
public function testCreateWithoutBegin()
{
$timesheet = new Timesheet();
$request = new Request();
$dateTime = (new UserDateTimeFactoryFactory($this))->create();
$sut = new PunchInOutMode($dateTime);
$sut->create($timesheet, $request);
self::assertInstanceOf(\DateTime::class, $timesheet->getBegin());
}
}