use timesheet description in invoices (#1079)
This commit is contained in:
@@ -50,24 +50,19 @@ abstract class AbstractCalculatorTest extends TestCase
|
||||
$template = new InvoiceTemplate();
|
||||
$template->setVat(19);
|
||||
|
||||
$user = $this->getMockBuilder(User::class)->setMethods(['getId'])->disableOriginalConstructor()->getMock();
|
||||
$user->method('getId')->willReturn(1);
|
||||
|
||||
$project = $this->getMockBuilder(Project::class)->setMethods(['getId', 'getCustomer', 'getName'])->disableOriginalConstructor()->getMock();
|
||||
$project->method('getId')->willReturn(1);
|
||||
$project->method('getCustomer')->willReturn($customer);
|
||||
$project->method('getName')->willReturn('project description');
|
||||
|
||||
$project1 = $this->getMockBuilder(Project::class)->setMethods(['getId', 'getName'])->disableOriginalConstructor()->getMock();
|
||||
$project1->method('getId')->willReturn(1);
|
||||
$project1->method('getName')->willReturn('bar');
|
||||
|
||||
$activity = $this->getMockBuilder(Activity::class)->setMethods(['getId', 'getProject', 'getName'])->disableOriginalConstructor()->getMock();
|
||||
$activity->method('getId')->willReturn(1);
|
||||
$activity->method('getProject')->willReturn($project);
|
||||
$activity->method('getName')->willReturn('activity description');
|
||||
|
||||
$activity1 = $this->getMockBuilder(Activity::class)->setMethods(['getId', 'getName'])->disableOriginalConstructor()->getMock();
|
||||
$activity1->method('getId')->willReturn(1);
|
||||
$activity1->method('getName')->willReturn('foo');
|
||||
|
||||
$query = new InvoiceQuery();
|
||||
if ($addProject === true) {
|
||||
$query->setProject($project);
|
||||
@@ -81,9 +76,9 @@ abstract class AbstractCalculatorTest extends TestCase
|
||||
->setBegin(new \DateTime())
|
||||
->setDuration(3600)
|
||||
->setRate(293.27)
|
||||
->setUser(new User())
|
||||
->setActivity($activity1)
|
||||
->setProject($project1);
|
||||
->setUser($user)
|
||||
->setActivity($activity)
|
||||
->setProject($project);
|
||||
|
||||
$model = new InvoiceModel();
|
||||
$model->setCustomer($customer);
|
||||
@@ -101,7 +96,7 @@ abstract class AbstractCalculatorTest extends TestCase
|
||||
} elseif ($addActivity === true) {
|
||||
$this->assertEquals('activity description', $result->getDescription());
|
||||
} else {
|
||||
$this->assertEquals('foo', $result->getDescription());
|
||||
$this->assertEquals('timesheet description', $result->getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,18 +128,8 @@ class ActivityInvoiceCalculatorTest extends AbstractCalculatorTest
|
||||
$this->assertEquals(84, $entries[2]->getRate());
|
||||
}
|
||||
|
||||
public function testDescriptionByTimesheet()
|
||||
{
|
||||
$this->assertDescription(new ActivityInvoiceCalculator(), false, false);
|
||||
}
|
||||
|
||||
public function testDescriptionByActivity()
|
||||
{
|
||||
$this->assertDescription(new ActivityInvoiceCalculator(), false, true);
|
||||
}
|
||||
|
||||
public function testDescriptionByProject()
|
||||
{
|
||||
$this->assertDescription(new ActivityInvoiceCalculator(), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,14 +135,4 @@ class DateInvoiceCalculatorTest extends AbstractCalculatorTest
|
||||
{
|
||||
$this->assertDescription(new DateInvoiceCalculator(), false, false);
|
||||
}
|
||||
|
||||
public function testDescriptionByActivity()
|
||||
{
|
||||
$this->assertDescription(new DateInvoiceCalculator(), false, true);
|
||||
}
|
||||
|
||||
public function testDescriptionByProject()
|
||||
{
|
||||
$this->assertDescription(new DateInvoiceCalculator(), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,18 +35,21 @@ class DefaultCalculatorTest extends AbstractCalculatorTest
|
||||
$template->setVat(19);
|
||||
|
||||
$timesheet = new Timesheet();
|
||||
$timesheet->setDescription('foo 1');
|
||||
$timesheet->setBegin(new \DateTime());
|
||||
$timesheet->setDuration(3600);
|
||||
$timesheet->setRate(293.27);
|
||||
$timesheet->setActivity(new Activity());
|
||||
|
||||
$timesheet2 = new Timesheet();
|
||||
$timesheet2->setDescription('foo 2');
|
||||
$timesheet2->setBegin(new \DateTime());
|
||||
$timesheet2->setDuration(400);
|
||||
$timesheet2->setRate(84);
|
||||
$timesheet2->setActivity(new Activity());
|
||||
|
||||
$timesheet3 = new Timesheet();
|
||||
$timesheet3->setDescription('foo 3');
|
||||
$timesheet3->setBegin(new \DateTime());
|
||||
$timesheet3->setDuration(1800);
|
||||
$timesheet3->setRate(111.11);
|
||||
|
||||
@@ -131,16 +131,6 @@ class ProjectInvoiceCalculatorTest extends AbstractCalculatorTest
|
||||
self::assertEquals(2521.12, $entries[0]->getRate() + $entries[1]->getRate() + $entries[2]->getRate());
|
||||
}
|
||||
|
||||
public function testDescriptionByTimesheet()
|
||||
{
|
||||
$this->assertDescription(new ProjectInvoiceCalculator(), false, false);
|
||||
}
|
||||
|
||||
public function testDescriptionByActivity()
|
||||
{
|
||||
$this->assertDescription(new ProjectInvoiceCalculator(), false, true);
|
||||
}
|
||||
|
||||
public function testDescriptionByProject()
|
||||
{
|
||||
$this->assertDescription(new ProjectInvoiceCalculator(), true, false);
|
||||
|
||||
@@ -190,14 +190,4 @@ class ShortInvoiceCalculatorTest extends AbstractCalculatorTest
|
||||
{
|
||||
$this->assertDescription(new ShortInvoiceCalculator(), false, false);
|
||||
}
|
||||
|
||||
public function testDescriptionByActivity()
|
||||
{
|
||||
$this->assertDescription(new ShortInvoiceCalculator(), false, true);
|
||||
}
|
||||
|
||||
public function testDescriptionByProject()
|
||||
{
|
||||
$this->assertDescription(new ShortInvoiceCalculator(), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@ class UserInvoiceCalculatorTest extends AbstractCalculatorTest
|
||||
$user2 = $this->getMockBuilder(User::class)->setMethods(['getId'])->disableOriginalConstructor()->getMock();
|
||||
$user2->method('getId')->willReturn(2);
|
||||
|
||||
$user3 = $this->getMockBuilder(User::class)->setMethods(['getId'])->disableOriginalConstructor()->getMock();
|
||||
$user3->method('getId')->willReturn(3);
|
||||
|
||||
$timesheet = new Timesheet();
|
||||
$timesheet
|
||||
->setBegin(new \DateTime())
|
||||
@@ -92,7 +95,7 @@ class UserInvoiceCalculatorTest extends AbstractCalculatorTest
|
||||
->setEnd(new \DateTime())
|
||||
->setDuration(400)
|
||||
->setRate(84)
|
||||
->setUser(new User())
|
||||
->setUser($user3)
|
||||
->setActivity($activity)
|
||||
->setProject((new Project())->setName('bar'));
|
||||
|
||||
@@ -128,14 +131,4 @@ class UserInvoiceCalculatorTest extends AbstractCalculatorTest
|
||||
{
|
||||
$this->assertDescription(new UserInvoiceCalculator(), false, false);
|
||||
}
|
||||
|
||||
public function testDescriptionByActivity()
|
||||
{
|
||||
$this->assertDescription(new UserInvoiceCalculator(), false, true);
|
||||
}
|
||||
|
||||
public function testDescriptionByProject()
|
||||
{
|
||||
$this->assertDescription(new UserInvoiceCalculator(), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user