Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)

This commit is contained in:
Kevin Papst
2022-12-31 21:19:55 +01:00
committed by GitHub
parent 95e06746bd
commit 90a0fd8a22
2164 changed files with 83700 additions and 86426 deletions

View File

@@ -20,7 +20,7 @@ abstract class AbstractCustomerEventTest extends TestCase
public function testGetterAndSetter()
{
$customer = new Customer();
$customer = new Customer('foo');
$sut = $this->createCustomerEvent($customer);
self::assertInstanceOf(Event::class, $sut);

View File

@@ -11,9 +11,7 @@ namespace App\Tests\Event;
use App\Event\ConfigureMainMenuEvent;
use App\Utils\MenuItemModel;
use KevinPapst\AdminLTEBundle\Event\SidebarMenuEvent;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
/**
* @covers \App\Event\ConfigureMainMenuEvent
@@ -22,15 +20,30 @@ class ConfigureMainMenuEventTest extends TestCase
{
public function testGetterAndSetter()
{
$request = new Request();
$event = new SidebarMenuEvent();
$admin = new MenuItemModel('admin', 'admin', 'admin');
$system = new MenuItemModel('system', 'system', 'system');
$sut = new ConfigureMainMenuEvent($request, $event, $admin, $system);
$sut = new ConfigureMainMenuEvent();
self::assertSame($request, $sut->getRequest());
self::assertSame($event, $sut->getMenu());
self::assertSame($admin, $sut->getAdminMenu());
self::assertSame($system, $sut->getSystemMenu());
self::assertNotNull($sut->getMenu());
self::assertNotNull($sut->getAdminMenu());
self::assertNotNull($sut->getAppsMenu());
self::assertNotNull($sut->getSystemMenu());
self::assertNull($sut->getTimesheetMenu());
self::assertNull($sut->getInvoiceMenu());
self::assertNull($sut->getReportingMenu());
$timesheet = new MenuItemModel('timesheet', 'timesheet');
$sut->getMenu()->addChild($timesheet);
self::assertNotNull($sut->getTimesheetMenu());
self::assertSame($timesheet, $sut->getTimesheetMenu());
$invoice = new MenuItemModel('invoice', 'invoice');
$sut->getMenu()->addChild($invoice);
self::assertNotNull($sut->getInvoiceMenu());
self::assertSame($invoice, $sut->getInvoiceMenu());
$reporting = new MenuItemModel('reporting', 'reporting');
$sut->getMenu()->addChild($reporting);
self::assertNotNull($sut->getReportingMenu());
self::assertSame($reporting, $sut->getReportingMenu());
}
}

View File

@@ -27,7 +27,7 @@ class CustomerDetailControllerEventTest extends AbstractCustomerEventTest
public function testController(): void
{
/** @var CustomerDetailControllerEvent $event */
$event = $this->createCustomerEvent(new Customer());
$event = $this->createCustomerEvent(new Customer('foo'));
$event->addController('Foo\\Bar::helloWorld');
$this->assertEquals(['Foo\\Bar::helloWorld'], $event->getController());
}

View File

@@ -20,7 +20,7 @@ class CustomerMetaDefinitionEventTest extends TestCase
{
public function testGetterAndSetter()
{
$customer = new Customer();
$customer = new Customer('foo');
$sut = new CustomerMetaDefinitionEvent($customer);
$this->assertSame($customer, $sut->getEntity());
}

View File

@@ -27,7 +27,7 @@ class CustomerStatisticEventTest extends AbstractCustomerEventTest
public function testStatistic()
{
$customer = new Customer();
$customer = new Customer('foo');
$statistic = new CustomerStatistic();
$sut = new CustomerStatisticEvent($customer, $statistic);

View File

@@ -11,7 +11,6 @@ namespace App\Tests\Event;
use App\Entity\User;
use App\Event\DashboardEvent;
use App\Widget\Type\CompoundRow;
use PHPUnit\Framework\TestCase;
/**
@@ -27,11 +26,13 @@ class DashboardEventTest extends TestCase
$sut = new DashboardEvent($user);
$this->assertEquals($user, $sut->getUser());
$this->assertEquals([], $sut->getSections());
$section = new CompoundRow();
$sut->addSection($section);
$sut->addWidget('test');
$sut->addWidget('test2', 5);
$sut->addWidget('test3', 45);
$sut->addWidget('test4', 10);
$sut->addWidget('test5', 5);
$this->assertEquals([$section], $sut->getSections());
$this->assertSame([0 => 'test', 5 => 'test2', 6 => 'test5', 10 => 'test4', 45 => 'test3'], $sut->getWidgets());
}
}

View File

@@ -9,8 +9,8 @@
namespace App\Tests\Event;
use App\Entity\InvoiceDocument;
use App\Event\InvoiceDocumentsEvent;
use App\Model\InvoiceDocument;
use PHPUnit\Framework\TestCase;
/**

View File

@@ -9,8 +9,8 @@
namespace App\Tests\Event;
use App\Entity\InvoiceDocument;
use App\Event\InvoicePostRenderEvent;
use App\Model\InvoiceDocument;
use App\Tests\Invoice\DebugFormatter;
use App\Tests\Invoice\Renderer\DebugRenderer;
use App\Tests\Mocks\InvoiceModelFactoryFactory;

View File

@@ -9,8 +9,8 @@
namespace App\Tests\Event;
use App\Entity\InvoiceDocument;
use App\Event\InvoicePreRenderEvent;
use App\Model\InvoiceDocument;
use App\Tests\Invoice\DebugFormatter;
use App\Tests\Invoice\Renderer\DebugRenderer;
use App\Tests\Mocks\InvoiceModelFactoryFactory;

View File

@@ -26,6 +26,7 @@ class PageActionsEventTest extends TestCase
$sut = new PageActionsEvent($user, [], 'foo', 'bar');
$this->assertEquals('bar', $sut->getView());
$this->assertEquals('foo', $sut->getActionName());
$this->assertEquals('actions.foo', $sut->getEventName());
$this->assertTrue($sut->isView('bar'));
$this->assertFalse($sut->isView('foo'));
$this->assertFalse($sut->isIndexView());
@@ -82,28 +83,21 @@ class PageActionsEventTest extends TestCase
{
$sut = new PageActionsEvent(new User(), ['hello' => 'world'], 'foo', 'xxx');
$sut->addSearchToggle();
$sut->addDivider();
$sut->addBack('foo1');
$sut->addColumnToggle('foo2');
$sut->addDelete('foo3');
$sut->addHelp('foo4');
$sut->addCreate('foo5', true);
$sut->addCreate('foo6', false);
$sut->addQuickExport('foo7');
$this->assertEquals(8, $sut->countActions());
$expected = [
'search' => ['modal' => '#modal_search', 'label' => null, 'accesskey' => 'q'],
'divider0' => null,
'back' => ['url' => 'foo1', 'translation_domain' => 'actions'],
'visibility' => ['modal' => '#foo2'],
'help' => ['url' => 'foo4', 'target' => '_blank', 'accesskey' => 'h'],
'create' => ['url' => 'foo5', 'class' => 'modal-ajax-form', 'accesskey' => 'a'],
'download' => ['url' => 'foo7', 'class' => 'toolbar-action'],
'trash' => ['url' => 'foo3', 'class' => 'modal-ajax-form text-red'],
'columns' => ['modal' => '#foo2', 'title' => 'modal.columns.title'],
'create' => ['url' => 'foo5', 'class' => 'modal-ajax-form', 'title' => 'create', 'accesskey' => 'a'],
'download' => ['url' => 'foo7', 'class' => 'toolbar-action', 'title' => 'export'],
'trash' => ['url' => 'foo3', 'class' => 'modal-ajax-form text-red', 'translation_domain' => 'actions'],
];
$this->assertEquals(\count($expected), $sut->countActions());
$this->assertEquals($expected, $sut->getActions());
}
@@ -114,13 +108,13 @@ class PageActionsEventTest extends TestCase
// make sure that modal always start with #, no matter what was given
$sut->addColumnToggle('#fooX');
$this->assertEquals(['visibility' => ['modal' => '#fooX']], $sut->getActions());
$this->assertEquals(['columns' => ['modal' => '#fooX', 'title' => 'modal.columns.title']], $sut->getActions());
// make sure that a second toggle cannot be added
$sut->addColumnToggle('fooY');
$this->assertEquals(['visibility' => ['modal' => '#fooX']], $sut->getActions());
$this->assertEquals(['columns' => ['modal' => '#fooX', 'title' => 'modal.columns.title']], $sut->getActions());
$sut->removeAction('visibility');
$sut->removeAction('columns');
$sut->addColumnToggle('fooY');
$this->assertEquals(['visibility' => ['modal' => '#fooY']], $sut->getActions());
$this->assertEquals(['columns' => ['modal' => '#fooY', 'title' => 'modal.columns.title']], $sut->getActions());
}
}

View File

@@ -22,7 +22,6 @@ class PrepareUserEventTest extends TestCase
{
$user = new User();
$sut = new PrepareUserEvent($user);
$this->assertEquals(PrepareUserEvent::class, PrepareUserEvent::PREPARE);
$this->assertSame($user, $sut->getUser());
}
}

View File

@@ -23,7 +23,7 @@ class RevenueStatisticEventTest extends TestCase
self::assertNull($sut->getEnd());
self::assertNull($sut->getBegin());
self::assertSame(0.0, $sut->getRevenue());
self::assertSame([], $sut->getRevenue());
$end = new \DateTime();
$begin = new \DateTime();
@@ -32,13 +32,13 @@ class RevenueStatisticEventTest extends TestCase
self::assertSame($begin, $sut->getBegin());
self::assertSame($end, $sut->getEnd());
self::assertSame(0.0, $sut->getRevenue());
self::assertSame([], $sut->getRevenue());
$sut->addRevenue(13.45);
$sut->addRevenue(6.55);
$sut->addRevenue(111);
$sut->addRevenue(2222.22);
$sut->addRevenue('EUR', 13.45);
$sut->addRevenue('EUR', 6.55);
$sut->addRevenue('EUR', 111);
$sut->addRevenue('EUR', 2222.22);
self::assertSame(2353.22, $sut->getRevenue());
self::assertSame(['EUR' => 2353.22], $sut->getRevenue());
}
}

View File

@@ -27,8 +27,8 @@ class SystemConfigurationEventTest extends TestCase
self::assertInstanceOf(SystemConfigurationEvent::class, $sut->addConfiguration(new SystemConfiguration()));
self::assertCount(1, $sut->getConfigurations());
$config = new Configuration();
$config->setName('foo')->setValue('bar');
$config = new Configuration('foo');
$config->setValue('bar');
$sysConfig = new SystemConfiguration();
$sysConfig->setConfiguration([$config]);
$sut = new SystemConfigurationEvent([$sysConfig]);

View File

@@ -17,11 +17,13 @@ use PHPUnit\Framework\TestCase;
*/
class ThemeJavascriptTranslationsEventTest extends TestCase
{
public const COUNTER = 17;
public function testDefaultValues()
{
$sut = new ThemeJavascriptTranslationsEvent();
$this->assertCount(24, $sut->getTranslations());
$this->assertCount(self::COUNTER, $sut->getTranslations());
}
public function testGetterAndSetter()
@@ -31,7 +33,7 @@ class ThemeJavascriptTranslationsEventTest extends TestCase
$sut->setTranslation('hello', 'world', 'testing');
$result = $sut->getTranslations();
self::assertCount(26, $result);
self::assertCount(self::COUNTER + 2, $result);
self::assertArrayHasKey('foo', $result);
self::assertEquals(['bar', 'messages'], $result['foo']);
self::assertArrayHasKey('hello', $result);

View File

@@ -25,8 +25,7 @@ class UserPreferenceDisplayEventTest extends TestCase
self::assertIsArray($sut->getPreferences());
self::assertEmpty($sut->getPreferences());
$preference = new UserPreference();
$preference->setName('foo')->setValue('bar');
$preference = new UserPreference('foo', 'bar');
$sut->addPreference($preference);
self::assertEquals([$preference], $sut->getPreferences());

View File

@@ -23,8 +23,7 @@ class UserPreferenceEventTest extends TestCase
{
$user = new User();
$user->setAlias('foo');
$pref = new UserPreference();
$pref->setName('foo')->setValue('bar');
$pref = new UserPreference('foo', 'bar');
$sut = new UserPreferenceEvent($user, []);
@@ -42,36 +41,12 @@ class UserPreferenceEventTest extends TestCase
$user = new User();
$user->setAlias('foo');
$pref = new UserPreference();
$pref->setName('foo')->setValue('bar');
$pref2 = new UserPreference();
$pref2->setName('foo')->setValue('hello');
$pref = new UserPreference('foo', 'bar');
$pref2 = new UserPreference('foo', 'hello');
$sut = new UserPreferenceEvent($user, []);
$sut->addPreference($pref);
$sut->addPreference($pref2);
}
/**
* @group legacy
*/
public function testDeprecations()
{
$this->expectException(\InvalidArgumentException::class);
$user = new User();
$user->setAlias('foo');
$pref = new UserPreference();
$pref->setName('foo')->setValue('bar');
$pref2 = new UserPreference();
$pref2->setName('foo')->setValue('hello');
$sut = new UserPreferenceEvent($user, []);
$sut->addUserPreference($pref); // change me, once the deprecated method will be deleted
$sut->addUserPreference($pref2); // change me, once the deprecated method will be deleted
}
}

View File

@@ -26,7 +26,7 @@ class UserRevenueStatisticEventTest extends TestCase
self::assertSame($user, $sut->getUser());
self::assertNull($sut->getEnd());
self::assertNull($sut->getBegin());
self::assertSame(0.0, $sut->getRevenue());
self::assertSame([], $sut->getRevenue());
$end = new \DateTime();
$begin = new \DateTime();
@@ -36,13 +36,13 @@ class UserRevenueStatisticEventTest extends TestCase
self::assertSame($user, $sut->getUser());
self::assertSame($begin, $sut->getBegin());
self::assertSame($end, $sut->getEnd());
self::assertSame(0.0, $sut->getRevenue());
self::assertSame([], $sut->getRevenue());
$sut->addRevenue(13.45);
$sut->addRevenue(6.55);
$sut->addRevenue(111);
$sut->addRevenue(2222.22);
$sut->addRevenue('CAD', 13.45);
$sut->addRevenue('CAD', 6.55);
$sut->addRevenue('CAD', 111);
$sut->addRevenue('CAD', 2222.22);
self::assertSame(2353.22, $sut->getRevenue());
self::assertSame(['CAD' => 2353.22], $sut->getRevenue());
}
}