added events for timesheet actions (#1598)

This commit is contained in:
Lukas
2020-04-15 18:07:14 +02:00
committed by GitHub
parent be00a519b3
commit 7b25e9acaf
27 changed files with 572 additions and 10 deletions

View File

@@ -0,0 +1,29 @@
<?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\Event;
use App\Entity\Timesheet;
use App\Event\AbstractTimesheetEvent;
use PHPUnit\Framework\TestCase;
use Symfony\Contracts\EventDispatcher\Event;
abstract class AbstractTimesheetEventTest extends TestCase
{
abstract protected function createTimesheetEvent(Timesheet $timesheet): AbstractTimesheetEvent;
public function testGetterAndSetter()
{
$timesheet = new Timesheet();
$sut = $this->createTimesheetEvent($timesheet);
self::assertInstanceOf(Event::class, $sut);
self::assertSame($timesheet, $sut->getTimesheet());
}
}

View File

@@ -0,0 +1,29 @@
<?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\Event;
use App\Entity\Timesheet;
use App\Event\AbstractTimesheetMultipleEvent;
use PHPUnit\Framework\TestCase;
use Symfony\Contracts\EventDispatcher\Event;
abstract class AbstractTimesheetMultipleEventTest extends TestCase
{
abstract protected function createTimesheetMultipleEvent(array $timesheets): AbstractTimesheetMultipleEvent;
public function testGetterAndSetter()
{
$timesheets = [new Timesheet(), new Timesheet()];
$sut = $this->createTimesheetMultipleEvent($timesheets);
self::assertInstanceOf(Event::class, $sut);
self::assertSame($timesheets, $sut->getTimesheets());
}
}

View File

@@ -0,0 +1,26 @@
<?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\Event;
use App\Entity\Timesheet;
use App\Event\AbstractTimesheetEvent;
use App\Event\TimesheetCreatePostEvent;
/**
* @covers \App\Event\AbstractTimesheetEvent
* @covers \App\Event\TimesheetCreatePostEvent
*/
class TimesheetCreatePostEventTest extends AbstractTimesheetEventTest
{
protected function createTimesheetEvent(Timesheet $timesheet): AbstractTimesheetEvent
{
return new TimesheetCreatePostEvent($timesheet);
}
}

View File

@@ -0,0 +1,26 @@
<?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\Event;
use App\Entity\Timesheet;
use App\Event\AbstractTimesheetEvent;
use App\Event\TimesheetCreatePreEvent;
/**
* @covers \App\Event\AbstractTimesheetEvent
* @covers \App\Event\TimesheetCreatePreEvent
*/
class TimesheetCreatePreEventTest extends AbstractTimesheetEventTest
{
protected function createTimesheetEvent(Timesheet $timesheet): AbstractTimesheetEvent
{
return new TimesheetCreatePreEvent($timesheet);
}
}

View File

@@ -0,0 +1,25 @@
<?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\Event;
use App\Event\AbstractTimesheetMultipleEvent;
use App\Event\TimesheetDeleteMultiplePreEvent;
/**
* @covers \App\Event\AbstractTimesheetMultipleEvent
* @covers \App\Event\TimesheetDeleteMultiplePreEvent
*/
class TimesheetDeleteMultiplePreEventTest extends AbstractTimesheetMultipleEventTest
{
protected function createTimesheetMultipleEvent(array $timesheets): AbstractTimesheetMultipleEvent
{
return new TimesheetDeleteMultiplePreEvent($timesheets);
}
}

View File

@@ -0,0 +1,26 @@
<?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\Event;
use App\Entity\Timesheet;
use App\Event\AbstractTimesheetEvent;
use App\Event\TimesheetDeletePreEvent;
/**
* @covers \App\Event\AbstractTimesheetEvent
* @covers \App\Event\TimesheetDeletePreEvent
*/
class TimesheetDeletePreEventTest extends AbstractTimesheetEventTest
{
protected function createTimesheetEvent(Timesheet $timesheet): AbstractTimesheetEvent
{
return new TimesheetDeletePreEvent($timesheet);
}
}

View File

@@ -0,0 +1,26 @@
<?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\Event;
use App\Entity\Timesheet;
use App\Event\AbstractTimesheetEvent;
use App\Event\TimesheetStopPostEvent;
/**
* @covers \App\Event\AbstractTimesheetEvent
* @covers \App\Event\TimesheetStopPostEvent
*/
class TimesheetStopPostEventTest extends AbstractTimesheetEventTest
{
protected function createTimesheetEvent(Timesheet $timesheet): AbstractTimesheetEvent
{
return new TimesheetStopPostEvent($timesheet);
}
}

View File

@@ -0,0 +1,26 @@
<?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\Event;
use App\Entity\Timesheet;
use App\Event\AbstractTimesheetEvent;
use App\Event\TimesheetStopPreEvent;
/**
* @covers \App\Event\AbstractTimesheetEvent
* @covers \App\Event\TimesheetStopPreEvent
*/
class TimesheetStopPreEventTest extends AbstractTimesheetEventTest
{
protected function createTimesheetEvent(Timesheet $timesheet): AbstractTimesheetEvent
{
return new TimesheetStopPreEvent($timesheet);
}
}

View File

@@ -0,0 +1,25 @@
<?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\Event;
use App\Event\AbstractTimesheetMultipleEvent;
use App\Event\TimesheetUpdateMultiplePostEvent;
/**
* @covers \App\Event\AbstractTimesheetMultipleEvent
* @covers \App\Event\TimesheetUpdateMultiplePostEvent
*/
class TimesheetUpdateMultiplePostEventTest extends AbstractTimesheetMultipleEventTest
{
protected function createTimesheetMultipleEvent(array $timesheets): AbstractTimesheetMultipleEvent
{
return new TimesheetUpdateMultiplePostEvent($timesheets);
}
}

View File

@@ -0,0 +1,25 @@
<?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\Event;
use App\Event\AbstractTimesheetMultipleEvent;
use App\Event\TimesheetUpdateMultiplePreEvent;
/**
* @covers \App\Event\AbstractTimesheetMultipleEvent
* @covers \App\Event\TimesheetUpdateMultiplePreEvent
*/
class TimesheetUpdateMultiplePreEventTest extends AbstractTimesheetMultipleEventTest
{
protected function createTimesheetMultipleEvent(array $timesheets): AbstractTimesheetMultipleEvent
{
return new TimesheetUpdateMultiplePreEvent($timesheets);
}
}

View File

@@ -0,0 +1,26 @@
<?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\Event;
use App\Entity\Timesheet;
use App\Event\AbstractTimesheetEvent;
use App\Event\TimesheetUpdatePostEvent;
/**
* @covers \App\Event\AbstractTimesheetEvent
* @covers \App\Event\TimesheetUpdatePostEvent
*/
class TimesheetUpdatePostEventTest extends AbstractTimesheetEventTest
{
protected function createTimesheetEvent(Timesheet $timesheet): AbstractTimesheetEvent
{
return new TimesheetUpdatePostEvent($timesheet);
}
}

View File

@@ -0,0 +1,26 @@
<?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\Event;
use App\Entity\Timesheet;
use App\Event\AbstractTimesheetEvent;
use App\Event\TimesheetUpdatePreEvent;
/**
* @covers \App\Event\AbstractTimesheetEvent
* @covers \App\Event\TimesheetUpdatePreEvent
*/
class TimesheetUpdatePreEventTest extends AbstractTimesheetEventTest
{
protected function createTimesheetEvent(Timesheet $timesheet): AbstractTimesheetEvent
{
return new TimesheetUpdatePreEvent($timesheet);
}
}