2020-03-01 18:21:16 +01:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-03-01 18:21:16 +01:00
|
|
|
namespace Engelsystem\Test\Unit\Controllers;
|
|
|
|
|
2023-02-02 22:53:51 +01:00
|
|
|
use Engelsystem\Controllers\NotificationType;
|
2020-03-01 18:21:16 +01:00
|
|
|
use Engelsystem\Test\Unit\Controllers\Stub\HasUserNotificationsImplementation;
|
|
|
|
use Engelsystem\Test\Unit\TestCase;
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
use Symfony\Component\HttpFoundation\Session\Session;
|
|
|
|
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
|
|
|
|
|
|
|
|
class HasUserNotificationsTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Controllers\HasUserNotifications::getNotifications
|
|
|
|
* @covers \Engelsystem\Controllers\HasUserNotifications::addNotification
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testNotifications(): void
|
2020-03-01 18:21:16 +01:00
|
|
|
{
|
|
|
|
$session = new Session(new MockArraySessionStorage());
|
|
|
|
$this->app->instance('session', $session);
|
|
|
|
|
|
|
|
$notify = new HasUserNotificationsImplementation();
|
2023-02-02 22:53:51 +01:00
|
|
|
$notify->add('Foo', NotificationType::ERROR);
|
|
|
|
$notify->add('Bar', NotificationType::WARNING);
|
|
|
|
$notify->add(['Baz', 'Lorem'], NotificationType::INFORMATION);
|
|
|
|
$notify->add(['Hm', ['test'], 'some' => ['Uff', 'sum']], NotificationType::MESSAGE);
|
|
|
|
$notify->add(['some' => ['it']], NotificationType::MESSAGE);
|
2020-03-01 18:21:16 +01:00
|
|
|
|
|
|
|
$this->assertEquals([
|
2023-02-02 22:53:51 +01:00
|
|
|
NotificationType::ERROR->value => new Collection(['Foo']),
|
|
|
|
NotificationType::WARNING->value => new Collection(['Bar']),
|
|
|
|
NotificationType::INFORMATION->value => new Collection(['Baz', 'Lorem']),
|
|
|
|
NotificationType::MESSAGE->value => new Collection(['Hm', 'test', 'Uff', 'sum', 'it']),
|
2020-03-01 18:21:16 +01:00
|
|
|
], $notify->get());
|
|
|
|
}
|
|
|
|
}
|