refactored page actions to event subscriber (#2420)

This commit is contained in:
Kevin Papst
2021-03-15 14:18:44 +01:00
committed by GitHub
parent 9a2fd9ba91
commit e1c9af795c
117 changed files with 2403 additions and 815 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\EventSubscriber\Actions;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\EventSubscriber\Actions\AbstractActionsSubscriber
*/
abstract class AbstractActionsSubscriberTest extends TestCase
{
protected function assertGetSubscribedEvent(string $className, string $name)
{
$this->assertTrue(method_exists($className, 'getSubscribedEvents'));
$events = $className::getSubscribedEvents();
$actionName = array_keys($events)[0];
$config = $events[$actionName];
$this->assertEquals('actions.' . $name, $actionName);
$this->assertTrue(method_exists($className, $config[0]));
$this->assertEquals(1000, $config[1]);
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\ActivitiesSubscriber;
/**
* @covers \App\EventSubscriber\Actions\ActivitiesSubscriber
*/
class ActivitiesSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(ActivitiesSubscriber::class, 'activities');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\ActivitySubscriber;
/**
* @covers \App\EventSubscriber\Actions\ActivitySubscriber
*/
class ActivitySubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(ActivitySubscriber::class, 'activity');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\CalendarSubscriber;
/**
* @covers \App\EventSubscriber\Actions\CalendarSubscriber
*/
class CalendarSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(CalendarSubscriber::class, 'calendar');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\CustomerSubscriber;
/**
* @covers \App\EventSubscriber\Actions\CustomerSubscriber
*/
class CustomerSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(CustomerSubscriber::class, 'customer');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\CustomersSubscriber;
/**
* @covers \App\EventSubscriber\Actions\CustomersSubscriber
*/
class CustomersSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(CustomersSubscriber::class, 'customers');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\ExportSubscriber;
/**
* @covers \App\EventSubscriber\Actions\ExportSubscriber
*/
class ExportSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(ExportSubscriber::class, 'export');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\InvoiceArchiveSubscriber;
/**
* @covers \App\EventSubscriber\Actions\InvoiceArchiveSubscriber
*/
class InvoiceArchiveSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(InvoiceArchiveSubscriber::class, 'invoice_details');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\InvoiceTemplateSubscriber;
/**
* @covers \App\EventSubscriber\Actions\InvoiceTemplateSubscriber
*/
class InvoiceTemplateSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(InvoiceTemplateSubscriber::class, 'invoice_template');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\InvoiceTemplateUploadSubscriber;
/**
* @covers \App\EventSubscriber\Actions\InvoiceTemplateUploadSubscriber
*/
class InvoiceTemplateUploadSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(InvoiceTemplateUploadSubscriber::class, 'invoice_upload');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\InvoiceTemplatesSubscriber;
/**
* @covers \App\EventSubscriber\Actions\InvoiceTemplatesSubscriber
*/
class InvoiceTemplatesSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(InvoiceTemplatesSubscriber::class, 'invoice_templates');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\InvoicesSubscriber;
/**
* @covers \App\EventSubscriber\Actions\InvoicesSubscriber
*/
class InvoicesSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(InvoicesSubscriber::class, 'invoices');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\PermissionsSubscriber;
/**
* @covers \App\EventSubscriber\Actions\PermissionsSubscriber
*/
class PermissionsSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(PermissionsSubscriber::class, 'user_permissions');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\PluginSubscriber;
/**
* @covers \App\EventSubscriber\Actions\PluginSubscriber
*/
class PluginSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(PluginSubscriber::class, 'plugin');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\PluginsSubscriber;
/**
* @covers \App\EventSubscriber\Actions\PluginsSubscriber
*/
class PluginsSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(PluginsSubscriber::class, 'plugins');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\ProjectSubscriber;
/**
* @covers \App\EventSubscriber\Actions\ProjectSubscriber
*/
class ProjectSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(ProjectSubscriber::class, 'project');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\ProjectsSubscriber;
/**
* @covers \App\EventSubscriber\Actions\ProjectsSubscriber
*/
class ProjectsSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(ProjectsSubscriber::class, 'projects');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\ReportingSubscriber;
/**
* @covers \App\EventSubscriber\Actions\ReportingSubscriber
*/
class ReportingSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(ReportingSubscriber::class, 'reporting');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\SystemConfigurationSubscriber;
/**
* @covers \App\EventSubscriber\Actions\SystemConfigurationSubscriber
*/
class SystemConfigurationSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(SystemConfigurationSubscriber::class, 'system_configuration');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\TagSubscriber;
/**
* @covers \App\EventSubscriber\Actions\TagSubscriber
*/
class TagSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(TagSubscriber::class, 'tag');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\TagsSubscriber;
/**
* @covers \App\EventSubscriber\Actions\TagsSubscriber
*/
class TagsSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(TagsSubscriber::class, 'tags');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\TeamSubscriber;
/**
* @covers \App\EventSubscriber\Actions\TeamSubscriber
*/
class TeamSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(TeamSubscriber::class, 'team');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\TeamsSubscriber;
/**
* @covers \App\EventSubscriber\Actions\TeamsSubscriber
*/
class TeamsSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(TeamsSubscriber::class, 'teams');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\TimesheetMultiUpdateSubscriber;
/**
* @covers \App\EventSubscriber\Actions\TimesheetMultiUpdateSubscriber
*/
class TimesheetMultiUpdateSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(TimesheetMultiUpdateSubscriber::class, 'timesheets_multi_update');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\TimesheetSubscriber;
/**
* @covers \App\EventSubscriber\Actions\TimesheetSubscriber
*/
class TimesheetSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(TimesheetSubscriber::class, 'timesheet');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\TimesheetTeamMultiUpdateSubscriber;
/**
* @covers \App\EventSubscriber\Actions\TimesheetTeamMultiUpdateSubscriber
*/
class TimesheetTeamMultiUpdateSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(TimesheetTeamMultiUpdateSubscriber::class, 'timesheets_team_multi_update');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\TimesheetTeamSubscriber;
/**
* @covers \App\EventSubscriber\Actions\TimesheetTeamSubscriber
*/
class TimesheetTeamSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(TimesheetTeamSubscriber::class, 'timesheet_team');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\TimesheetsSubscriber;
/**
* @covers \App\EventSubscriber\Actions\TimesheetsSubscriber
*/
class TimesheetsSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(TimesheetsSubscriber::class, 'timesheets');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\TimesheetsTeamSubscriber;
/**
* @covers \App\EventSubscriber\Actions\TimesheetsTeamSubscriber
*/
class TimesheetsTeamSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(TimesheetsTeamSubscriber::class, 'timesheets_team');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\UserSubscriber;
/**
* @covers \App\EventSubscriber\Actions\UserSubscriber
*/
class UserSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(UserSubscriber::class, 'user');
}
}

View File

@@ -0,0 +1,23 @@
<?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\EventSubscriber\Actions;
use App\EventSubscriber\Actions\UsersSubscriber;
/**
* @covers \App\EventSubscriber\Actions\UsersSubscriber
*/
class UsersSubscriberTest extends AbstractActionsSubscriberTest
{
public function testEventName()
{
$this->assertGetSubscribedEvent(UsersSubscriber::class, 'users');
}
}