* deactivate deprecated auto-mapping * use native month-picker with fallback on old browser * bump dependencies to new major versions * replace deprecated ARRAY column type with JSON * named arguments * nullable arguments * native lazy ghosts * update routes to use php config * disable PHP < 8.4 * use static RTL configuration * new qr code package * clear out env file * recipe updates * fix deprecations * preset new env variable if not existing * bump maria db version examples * remove deprecated api-token support * fix validator deprecations * remove timesheet category column * fix broken validator autoconfiguration * stabilize tests * fix migration syntax compatibility * fix doctrine deprecation * fix datetime format * remove constructor dependency * only include visible preferences in invoice templates * fix test container dependency * removed ProjectConstraint multi-constraint logic * allow to disable plugins in certain environments * refactor TimesheetConstraint to non-service * activate new interface methods * prevent update issues with .env * improved customer fixture * removed $user->isExportDecimal()
58 lines
2.1 KiB
PHP
58 lines
2.1 KiB
PHP
<?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\ConfigureMainMenuEvent;
|
|
use App\Utils\MenuItemModel;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
#[CoversClass(ConfigureMainMenuEvent::class)]
|
|
class ConfigureMainMenuEventTest extends TestCase
|
|
{
|
|
public function testGetterAndSetter(): void
|
|
{
|
|
$sut = new ConfigureMainMenuEvent();
|
|
|
|
self::assertEquals('main', $sut->getMenu()->getIdentifier());
|
|
self::assertEquals('admin', $sut->getAdminMenu()->getIdentifier());
|
|
self::assertEquals('system', $sut->getSystemMenu()->getIdentifier());
|
|
|
|
self::assertNull($sut->getTimesheetMenu());
|
|
self::assertNull($sut->getInvoiceMenu());
|
|
self::assertNull($sut->getReportingMenu());
|
|
|
|
$timesheet = new MenuItemModel('times', 'timesheet');
|
|
$sut->getMenu()->addChild($timesheet);
|
|
self::assertNotNull($sut->getTimesheetMenu());
|
|
self::assertSame($timesheet, $sut->getTimesheetMenu());
|
|
|
|
$invoice = new MenuItemModel('invoices', 'invoice');
|
|
$sut->getMenu()->addChild($invoice);
|
|
self::assertNotNull($sut->getInvoiceMenu());
|
|
self::assertSame($invoice, $sut->getInvoiceMenu());
|
|
|
|
self::assertNull($sut->findById('reporting'));
|
|
self::assertNull($sut->findById('foo'));
|
|
self::assertNull($sut->findById('bar'));
|
|
|
|
$reporting = new MenuItemModel('reporting', 'reporting');
|
|
$sut->getMenu()->addChild($reporting);
|
|
$reporting->addChild(new MenuItemModel('foo', 'foo'));
|
|
$reporting->addChild(new MenuItemModel('bar', 'bar'));
|
|
self::assertNotNull($sut->getReportingMenu());
|
|
self::assertSame($reporting, $sut->getReportingMenu());
|
|
|
|
self::assertSame($reporting, $sut->findById('reporting')); // @phpstan-ignore argument.unresolvableType
|
|
self::assertNotNull($sut->findById('foo'));
|
|
self::assertNotNull($sut->findById('bar'));
|
|
}
|
|
}
|