validation for future and negative times (#512)

This commit is contained in:
Kevin Papst
2019-01-21 01:51:57 +01:00
committed by GitHub
parent 5b1ec1eb8f
commit 5539f68a54
6 changed files with 44 additions and 6 deletions

View File

@@ -47,6 +47,8 @@ class ActivityInvoiceCalculatorTest extends AbstractCalculatorTest
$timesheet = new Timesheet();
$timesheet
->setBegin(new \DateTime())
->setEnd(new \DateTime())
->setDuration(3600)
->setRate(293.27)
->setUser($user)
@@ -55,6 +57,8 @@ class ActivityInvoiceCalculatorTest extends AbstractCalculatorTest
$timesheet2 = new Timesheet();
$timesheet2
->setBegin(new \DateTime())
->setEnd(new \DateTime())
->setDuration(400)
->setRate(84.75)
->setUser($user)
@@ -63,6 +67,8 @@ class ActivityInvoiceCalculatorTest extends AbstractCalculatorTest
$timesheet3 = new Timesheet();
$timesheet3
->setBegin(new \DateTime())
->setEnd(new \DateTime())
->setDuration(1800)
->setRate(111.11)
->setUser($user)
@@ -71,6 +77,8 @@ class ActivityInvoiceCalculatorTest extends AbstractCalculatorTest
$timesheet4 = new Timesheet();
$timesheet4
->setBegin(new \DateTime())
->setEnd(new \DateTime())
->setDuration(400)
->setRate(1947.99)
->setUser($user)
@@ -79,6 +87,8 @@ class ActivityInvoiceCalculatorTest extends AbstractCalculatorTest
$timesheet5 = new Timesheet();
$timesheet5
->setBegin(new \DateTime())
->setEnd(new \DateTime())
->setDuration(400)
->setRate(84)
->setUser(new User())

View File

@@ -47,6 +47,8 @@ class UserInvoiceCalculatorTest extends AbstractCalculatorTest
$timesheet = new Timesheet();
$timesheet
->setBegin(new \DateTime())
->setEnd(new \DateTime())
->setDuration(3600)
->setRate(293.27)
->setUser($user1)
@@ -55,6 +57,8 @@ class UserInvoiceCalculatorTest extends AbstractCalculatorTest
$timesheet2 = new Timesheet();
$timesheet2
->setBegin(new \DateTime())
->setEnd(new \DateTime())
->setDuration(400)
->setRate(84.75)
->setUser($user2)
@@ -63,6 +67,8 @@ class UserInvoiceCalculatorTest extends AbstractCalculatorTest
$timesheet3 = new Timesheet();
$timesheet3
->setBegin(new \DateTime())
->setEnd(new \DateTime())
->setDuration(1800)
->setRate(111.11)
->setUser($user1)
@@ -71,6 +77,8 @@ class UserInvoiceCalculatorTest extends AbstractCalculatorTest
$timesheet4 = new Timesheet();
$timesheet4
->setBegin(new \DateTime())
->setEnd(new \DateTime())
->setDuration(400)
->setRate(1947.99)
->setUser($user2)
@@ -79,6 +87,8 @@ class UserInvoiceCalculatorTest extends AbstractCalculatorTest
$timesheet5 = new Timesheet();
$timesheet5
->setBegin(new \DateTime())
->setEnd(new \DateTime())
->setDuration(400)
->setRate(84)
->setUser(new User())

View File

@@ -160,6 +160,14 @@ class ExtensionsTest extends TestCase
// test fallback format
$sut = $this->getSut($this->localeEn, 'XX');
$this->assertEquals('02:37 h', $sut->duration($record->getDuration()));
// test negative duratiobn
$sut = $this->getSut($this->localeEn, 'XX');
$this->assertEquals('?', $sut->duration('-1'));
// test zero duration
$sut = $this->getSut($this->localeEn, 'XX');
$this->assertEquals('00:00 h', $sut->duration('0'));
}
protected function getTimesheet($seconds)