Added timesheet-calendar view (#236)

This commit is contained in:
Kevin Papst
2018-07-27 20:19:56 +02:00
committed by GitHub
parent 5ccc1c991b
commit e6f8bc8ae2
40 changed files with 1286 additions and 49 deletions

View File

@@ -0,0 +1,40 @@
<?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());
}
}

View File

@@ -0,0 +1,38 @@
<?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\Google;
use App\Calendar\Source;
use PHPUnit\Framework\TestCase;
/**
* @coversDefaultClass \App\Calendar\Google
*/
class GoogleTest extends TestCase
{
public function testConstruct()
{
$sources = [
(new Source())->setId('foo')->setColor('#ccc'),
(new Source())->setId('bar')->setUri('sdsdfsdfsdfsdffd'),
];
$sut = new Google('qwertzuiop1234567890');
$this->assertEquals([], $sut->getSources());
$this->assertEquals('qwertzuiop1234567890', $sut->getApiKey());
$sut = new Google('ewa6347865fg908ouhpoihui7f56', $sources);
$this->assertEquals($sources, $sut->getSources());
$this->assertEquals('ewa6347865fg908ouhpoihui7f56', $sut->getApiKey());
}
}

View File

@@ -0,0 +1,64 @@
<?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());
}
}

View File

@@ -0,0 +1,36 @@
<?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\Source;
use PHPUnit\Framework\TestCase;
/**
* @coversDefaultClass \App\Calendar\Source
*/
class SourceTest extends TestCase
{
public function testConstruct()
{
$sut = new Source();
$this->assertNull($sut->getId());
$this->assertNull($sut->getColor());
$this->assertNull($sut->getUri());
$this->assertInstanceOf(Source::class, $sut->setId('0815'));
$this->assertInstanceOf(Source::class, $sut->setColor('#fffccc'));
$this->assertInstanceOf(Source::class, $sut->setUri('askdjfhlaksjdhflaksjhdflkjasdlkfjh'));
$this->assertEquals('0815', $sut->getId());
$this->assertEquals('#fffccc', $sut->getColor());
$this->assertEquals('askdjfhlaksjdhflaksjhdflkjasdlkfjh', $sut->getUri());
}
}