added fixed-rate and hourly-rate for customer, project and activity (#304)

This commit is contained in:
Kevin Papst
2018-09-06 23:37:25 +02:00
committed by GitHub
parent 6163f33abf
commit 8cae5e8b3f
32 changed files with 1173 additions and 154 deletions

View File

@@ -0,0 +1,50 @@
<?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\Entity;
use App\Entity\Activity;
/**
* @covers \App\Entity\Activity
*/
class ActivityTest extends AbstractEntityTest
{
public function testDefaultValues()
{
$sut = new Activity();
$this->assertNull($sut->getId());
$this->assertNull($sut->getProject());
$this->assertNull($sut->getName());
$this->assertNull($sut->getComment());
$this->assertTrue($sut->getVisible());
// timesheets
$this->assertNull($sut->getFixedRate());
$this->assertNull($sut->getHourlyRate());
}
public function testSetterAndGetter()
{
$sut = new Activity();
$this->assertInstanceOf(Activity::class, $sut->setName('foo-bar'));
$this->assertEquals('foo-bar', $sut->getName());
$this->assertEquals('foo-bar', (string) $sut);
$this->assertInstanceOf(Activity::class, $sut->setVisible(false));
$this->assertFalse($sut->getVisible());
$this->assertInstanceOf(Activity::class, $sut->setComment('hello world'));
$this->assertEquals('hello world', $sut->getComment());
$this->assertInstanceOf(Activity::class, $sut->setFixedRate(13.47));
$this->assertEquals(13.47, $sut->getFixedRate());
$this->assertInstanceOf(Activity::class, $sut->setHourlyRate(99));
$this->assertEquals(99, $sut->getHourlyRate());
}
}

View File

@@ -0,0 +1,90 @@
<?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\Entity;
use App\Entity\Customer;
use App\Entity\Project;
/**
* @covers \App\Entity\Customer
*/
class CustomerTest extends AbstractEntityTest
{
public function testDefaultValues()
{
$sut = new Customer();
$this->assertNull($sut->getId());
$this->assertNull($sut->getName());
$this->assertNull($sut->getNumber());
$this->assertNull($sut->getComment());
// projects
$this->assertTrue($sut->getVisible());
$this->assertNull($sut->getCompany());
$this->assertNull($sut->getContact());
$this->assertNull($sut->getAddress());
$this->assertNull($sut->getCountry());
$this->assertEquals('EUR', $sut->getCurrency());
$this->assertEquals('EUR', Customer::DEFAULT_CURRENCY);
$this->assertNull($sut->getPhone());
$this->assertNull($sut->getFax());
$this->assertNull($sut->getMobile());
$this->assertNull($sut->getMail());
$this->assertNull($sut->getHomepage());
$this->assertNull($sut->getTimezone());
$this->assertNull($sut->getFixedRate());
$this->assertNull($sut->getHourlyRate());
}
public function testSetterAndGetter()
{
$sut = new Customer();
$this->assertInstanceOf(Customer::class, $sut->setName('foo-bar'));
$this->assertEquals('foo-bar', $sut->getName());
$this->assertEquals('foo-bar', (string) $sut);
$this->assertInstanceOf(Customer::class, $sut->setVisible(false));
$this->assertFalse($sut->getVisible());
$this->assertInstanceOf(Customer::class, $sut->setComment('hello world'));
$this->assertEquals('hello world', $sut->getComment());
$projects = [(new Project())->setName('Test')];
$this->assertInstanceOf(Customer::class, $sut->setProjects($projects));
$this->assertSame($projects, $sut->getProjects());
$this->assertInstanceOf(Customer::class, $sut->setCompany('test company'));
$this->assertEquals('test company', $sut->getCompany());
$this->assertInstanceOf(Customer::class, $sut->setContact('test contact'));
$this->assertEquals('test contact', $sut->getContact());
$this->assertInstanceOf(Customer::class, $sut->setPhone('0123456789'));
$this->assertEquals('0123456789', $sut->getPhone());
$this->assertInstanceOf(Customer::class, $sut->setFax('asdfghjkl'));
$this->assertEquals('asdfghjkl', $sut->getFax());
$this->assertInstanceOf(Customer::class, $sut->setMobile('76576534'));
$this->assertEquals('76576534', $sut->getMobile());
$this->assertInstanceOf(Customer::class, $sut->setMail('test@example.com'));
$this->assertEquals('test@example.com', $sut->getMail());
$this->assertInstanceOf(Customer::class, $sut->setHomepage('https://www.example.com'));
$this->assertEquals('https://www.example.com', $sut->getHomepage());
$this->assertInstanceOf(Customer::class, $sut->setFixedRate(13.47));
$this->assertEquals(13.47, $sut->getFixedRate());
$this->assertInstanceOf(Customer::class, $sut->setHourlyRate(99));
$this->assertEquals(99, $sut->getHourlyRate());
}
}

View File

@@ -0,0 +1,68 @@
<?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\Entity;
use App\Entity\Activity;
use App\Entity\Customer;
use App\Entity\Project;
/**
* @covers \App\Entity\Project
*/
class ProjectTest extends AbstractEntityTest
{
public function testDefaultValues()
{
$sut = new Project();
$this->assertNull($sut->getId());
$this->assertNull($sut->getCustomer());
$this->assertNull($sut->getName());
$this->assertNull($sut->getOrderNumber());
$this->assertNull($sut->getComment());
$this->assertTrue($sut->getVisible());
$this->assertEquals(0.0, $sut->getBudget());
// activities
$this->assertNull($sut->getFixedRate());
$this->assertNull($sut->getHourlyRate());
}
public function testSetterAndGetter()
{
$sut = new Project();
$customer = (new Customer())->setName('customer');
$this->assertInstanceOf(Project::class, $sut->setCustomer($customer));
$this->assertSame($customer, $sut->getCustomer());
$this->assertInstanceOf(Project::class, $sut->setName('123456789'));
$this->assertEquals('123456789', (string) $sut);
$this->assertInstanceOf(Project::class, $sut->setOrderNumber('123456789'));
$this->assertEquals('123456789', $sut->getOrderNumber());
$this->assertInstanceOf(Project::class, $sut->setComment('a comment'));
$this->assertEquals('a comment', $sut->getComment());
$this->assertInstanceOf(Project::class, $sut->setVisible(false));
$this->assertFalse($sut->getVisible());
$this->assertInstanceOf(Project::class, $sut->setBudget(12345.67));
$this->assertEquals(12345.67, $sut->getBudget());
$activities = [(new Activity())->setName('foo')];
$this->assertInstanceOf(Project::class, $sut->setActivities($activities));
$this->assertSame($activities, $sut->getActivities());
$this->assertInstanceOf(Project::class, $sut->setFixedRate(13.47));
$this->assertEquals(13.47, $sut->getFixedRate());
$this->assertInstanceOf(Project::class, $sut->setHourlyRate(99));
$this->assertEquals(99, $sut->getHourlyRate());
}
}