improved calendar (#784)
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
<?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\Calendar;
|
||||
|
||||
use App\Calendar\Config;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \App\Calendar\Config
|
||||
*/
|
||||
class ConfigTest extends TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$config = [
|
||||
'businessHours' => [
|
||||
'days' => [0, 99, 127],
|
||||
'begin' => '07:49',
|
||||
'end' => '19:27'
|
||||
],
|
||||
'day_limit' => 20,
|
||||
'week_numbers' => false,
|
||||
];
|
||||
|
||||
$sut = new Config($config);
|
||||
|
||||
$this->assertEquals([0, 99, 127], $sut->getBusinessDays());
|
||||
$this->assertEquals('07:49', $sut->getBusinessTimeBegin());
|
||||
$this->assertEquals('19:27', $sut->getBusinessTimeEnd());
|
||||
$this->assertEquals(20, $sut->getDayLimit());
|
||||
$this->assertFalse($sut->isShowWeekNumbers());
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
<?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\Calendar;
|
||||
|
||||
use App\Calendar\Config;
|
||||
use App\Calendar\Google;
|
||||
use App\Calendar\Service;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \App\Calendar\Service
|
||||
*/
|
||||
class ServiceTest extends TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$config = [
|
||||
'businessHours' => [
|
||||
'days' => [2, 4, 6],
|
||||
'begin' => '07:49',
|
||||
'end' => '19:27'
|
||||
],
|
||||
'day_limit' => 20,
|
||||
'week_numbers' => false,
|
||||
'google' => [
|
||||
'api_key' => 'wertwertwegsdfbdf243w567fg8ihuon',
|
||||
'sources' => [
|
||||
'holidays' => [
|
||||
'id' => 'de.german#holiday@group.v.calendar.google.com',
|
||||
'color' => '#ccc',
|
||||
],
|
||||
'holidays_en' => [
|
||||
'id' => 'en.german#holiday@group.v.calendar.google.com',
|
||||
'color' => '#fff',
|
||||
],
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$sut = new Service($config);
|
||||
|
||||
$config = $sut->getConfig();
|
||||
$this->assertInstanceOf(Config::class, $config);
|
||||
$this->assertEquals([2, 4, 6], $config->getBusinessDays());
|
||||
|
||||
$google = $sut->getGoogle();
|
||||
$this->assertInstanceOf(Google::class, $google);
|
||||
$this->assertEquals('wertwertwegsdfbdf243w567fg8ihuon', $google->getApiKey());
|
||||
|
||||
$sources = $google->getSources();
|
||||
$this->assertEquals(2, count($sources));
|
||||
$this->assertEquals('holidays', $sources[0]->getId());
|
||||
$this->assertEquals('#ccc', $sources[0]->getColor());
|
||||
$this->assertEquals('holidays_en', $sources[1]->getId());
|
||||
$this->assertEquals('#fff', $sources[1]->getColor());
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
<?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\Calendar;
|
||||
|
||||
use App\Calendar\TimesheetEntity;
|
||||
use App\Entity\Activity;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\Project;
|
||||
use App\Entity\Tag;
|
||||
use App\Entity\Timesheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \App\Calendar\TimesheetEntity
|
||||
*/
|
||||
class TimesheetEntityTest extends TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$activity = new Activity();
|
||||
$activity->setName('activity');
|
||||
|
||||
$customer = new Customer();
|
||||
$customer->setName('customer');
|
||||
|
||||
$project = new Project();
|
||||
$project->setName('project');
|
||||
$project->setCustomer($customer);
|
||||
|
||||
$timesheet = new Timesheet();
|
||||
$timesheet->setActivity($activity);
|
||||
$timesheet->setProject($project);
|
||||
$timesheet->addTag((new Tag())->setName('foo'));
|
||||
$timesheet->addTag((new Tag())->setName('bar'));
|
||||
|
||||
$sut = new TimesheetEntity($timesheet);
|
||||
|
||||
$this->assertEquals('customer', $sut->getCustomer());
|
||||
$this->assertEquals('project', $sut->getProject());
|
||||
$this->assertEquals('activity', $sut->getTitle());
|
||||
$this->assertEquals('foo, bar', $sut->getTags());
|
||||
|
||||
$sut->setId(13);
|
||||
$this->assertEquals(13, $sut->getId());
|
||||
|
||||
$date = new \DateTime('-13 hours');
|
||||
$sut->setStart($date);
|
||||
$this->assertEquals($date, $sut->getStart());
|
||||
|
||||
$date = new \DateTime('-3 hours');
|
||||
$sut->setEnd($date);
|
||||
$this->assertEquals($date, $sut->getEnd());
|
||||
|
||||
$sut->setTitle('sdfsdf');
|
||||
$this->assertEquals('sdfsdf', $sut->getTitle());
|
||||
|
||||
$sut->setCustomer('aaaaaaaa');
|
||||
$this->assertEquals('aaaaaaaa', $sut->getCustomer());
|
||||
|
||||
$sut->setProject('bbbbbbbbbb');
|
||||
$this->assertEquals('bbbbbbbbbb', $sut->getProject());
|
||||
|
||||
$sut->setActivity('cccccccc');
|
||||
$this->assertEquals('cccccccc', $sut->getActivity());
|
||||
|
||||
$sut->setTags('hello, world');
|
||||
$this->assertEquals('hello, world', $sut->getTags());
|
||||
|
||||
$this->assertNull($sut->getBorderColor());
|
||||
$sut->setBorderColor('#cccccc');
|
||||
$this->assertEquals('#cccccc', $sut->getBorderColor());
|
||||
|
||||
$this->assertNull($sut->getBackgroundColor());
|
||||
$sut->setBackgroundColor('#ffffff');
|
||||
$this->assertEquals('#ffffff', $sut->getBackgroundColor());
|
||||
|
||||
$sut->setDescription('foo-bar');
|
||||
$this->assertEquals('foo-bar', $sut->getDescription());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user