added drag and drop for new records via calendar (#1962)

This commit is contained in:
Kevin Papst
2020-09-17 01:13:48 +02:00
committed by GitHub
parent 14b3de4300
commit 9ef32e75c5
82 changed files with 2808 additions and 385 deletions

View File

@@ -9,28 +9,26 @@
namespace App\Tests\Calendar;
use App\Calendar\Source;
use App\Calendar\GoogleSource;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Calendar\Source
* @covers \App\Calendar\GoogleSource
*/
class SourceTest extends TestCase
class GoogleSourceTest 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'));
$sut = new GoogleSource('0815', 'askdjfhlaksjdhflaksjhdflkjasdlkfjh', '#fffccc');
$this->assertEquals('0815', $sut->getId());
$this->assertEquals('#fffccc', $sut->getColor());
$this->assertEquals('askdjfhlaksjdhflaksjhdflkjasdlkfjh', $sut->getUri());
$this->assertEquals('#fffccc', $sut->getColor());
$sut = new GoogleSource('0815', 'askdjfhlaksjdhflaksjhdflkjasdlkfjh', null);
$this->assertEquals('0815', $sut->getId());
$this->assertEquals('askdjfhlaksjdhflaksjhdflkjasdlkfjh', $sut->getUri());
$this->assertNull($sut->getColor());
}
}

View File

@@ -10,7 +10,7 @@
namespace App\Tests\Calendar;
use App\Calendar\Google;
use App\Calendar\Source;
use App\Calendar\GoogleSource;
use PHPUnit\Framework\TestCase;
/**
@@ -21,8 +21,8 @@ class GoogleTest extends TestCase
public function testConstruct()
{
$sources = [
(new Source())->setId('foo')->setColor('#ccc'),
(new Source())->setId('bar')->setUri('sdsdfsdfsdfsdffd'),
new GoogleSource('foo', '', '#ccc'),
new GoogleSource('bar', 'sdsdfsdfsdfsdffd'),
];
$sut = new Google('qwertzuiop1234567890');

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\RecentActivitiesSource;
use App\Calendar\TimesheetEntry;
use App\Entity\Timesheet;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Calendar\RecentActivitiesSource
*/
class RecentActivitiesSourceTest extends TestCase
{
public function testConstruct()
{
$entries = [new TimesheetEntry(new Timesheet(), '#cccccc')];
$sut = new RecentActivitiesSource($entries);
$this->assertEquals('calendar/drag-drop.html.twig', $sut->getBlockInclude());
$this->assertSame($entries, $sut->getEntries());
$this->assertEquals('POST', $sut->getMethod());
$this->assertEquals('post_timesheet', $sut->getRoute());
$this->assertEquals(['full' => 'true'], $sut->getRouteParams());
$this->assertEquals([], $sut->getRouteReplacer());
$this->assertEquals('recent.activities', $sut->getTitle());
}
}

View File

@@ -0,0 +1,99 @@
<?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\TimesheetEntry;
use App\Entity\Activity;
use App\Entity\Project;
use App\Entity\Tag;
use App\Entity\Timesheet;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Calendar\TimesheetEntry
*/
class TimesheetEntryTest extends TestCase
{
public function testConstruct()
{
$project = new Project();
$activity = new Activity();
$activity->setName('a wonderful activity!!');
$activity->setProject($project);
$timesheet = new Timesheet();
$timesheet->setActivity($activity);
$timesheet->setProject($project);
$timesheet->setDescription('hello foo bar');
$timesheet->addTag((new Tag())->setName('bulb'));
$timesheet->addTag((new Tag())->setName('action test'));
$expectedData = [
'description' => 'hello foo bar',
'activity' => null,
'project' => null,
'tags' => 'bulb,action test',
];
$sut = new TimesheetEntry($timesheet, '#cccccc');
$this->assertEquals('a wonderful activity!!', $sut->getTitle());
$this->assertEquals('#cccccc', $sut->getColor());
$this->assertSame($project, $sut->getProject());
$this->assertSame($activity, $sut->getActivity());
$this->assertEquals('dd_timesheet', $sut->getBlockName());
$this->assertEquals($expectedData, $sut->getData());
}
public function testEmpty()
{
$timesheet = new Timesheet();
$expectedData = [
'description' => null,
'activity' => null,
'project' => null,
'tags' => '',
];
$sut = new TimesheetEntry($timesheet, '#ddd');
$this->assertEquals('', $sut->getTitle());
$this->assertEquals('#ddd', $sut->getColor());
$this->assertNull($sut->getProject());
$this->assertNull($sut->getActivity());
$this->assertEquals($expectedData, $sut->getData());
}
public function testGetTitle()
{
$project = new Project();
$project->setName('sdfsdf');
$timesheet = new Timesheet();
$timesheet->setProject($project);
$sut = new TimesheetEntry($timesheet, '#ddd');
self::assertEquals('sdfsdf', $sut->getTitle());
$project = new Project();
$timesheet = new Timesheet();
$timesheet->setProject($project);
$sut = new TimesheetEntry($timesheet, '#ddd');
self::assertEquals('', $sut->getTitle());
$project = new Project();
$timesheet = new Timesheet();
$timesheet->setDescription('fooooo');
$timesheet->setProject($project);
$sut = new TimesheetEntry($timesheet, '#ddd');
self::assertEquals('fooooo', $sut->getTitle());
}
}