API endpoint for Timesheet entries (#332)
This commit is contained in:
39
tests/Event/ConfigureAdminMenuEventTest.php
Normal file
39
tests/Event/ConfigureAdminMenuEventTest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?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;
|
||||
|
||||
use App\Event\ConfigureAdminMenuEvent;
|
||||
use KevinPapst\AdminLTEBundle\Event\SidebarMenuEvent;
|
||||
use KevinPapst\AdminLTEBundle\Model\MenuItemModel;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @covers \App\Event\ConfigureAdminMenuEvent
|
||||
*/
|
||||
class ConfigureAdminMenuEventTest extends TestCase
|
||||
{
|
||||
public function testGetterAndSetter()
|
||||
{
|
||||
$request = new Request();
|
||||
$request->setLocale('de');
|
||||
|
||||
$event = new SidebarMenuEvent($request);
|
||||
$admin = new MenuItemModel('admin', 'foo', 'bar');
|
||||
$event->addItem($admin);
|
||||
$event->addItem(new MenuItemModel('foo', 'foo', 'bar'));
|
||||
|
||||
$sut = new ConfigureAdminMenuEvent($request, $event);
|
||||
|
||||
$this->assertEquals($request, $sut->getRequest());
|
||||
$this->assertEquals($event, $sut->getMenu());
|
||||
$this->assertEquals($admin, $sut->getAdminMenu());
|
||||
}
|
||||
}
|
||||
37
tests/Event/DashboardEventTest.php
Normal file
37
tests/Event/DashboardEventTest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Event\DashboardEvent;
|
||||
use App\Model\DashboardSection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Event\DashboardEvent
|
||||
*/
|
||||
class DashboardEventTest extends TestCase
|
||||
{
|
||||
public function testGetterAndSetter()
|
||||
{
|
||||
$user = new User();
|
||||
$user->setAlias('foo');
|
||||
|
||||
$sut = new DashboardEvent($user);
|
||||
|
||||
$this->assertEquals($user, $sut->getUser());
|
||||
$this->assertEquals([], $sut->getSections());
|
||||
|
||||
$section = new DashboardSection('foo');
|
||||
$sut->addSection($section);
|
||||
|
||||
$this->assertEquals([$section], $sut->getSections());
|
||||
}
|
||||
}
|
||||
57
tests/Event/UserPreferenceEventTest.php
Normal file
57
tests/Event/UserPreferenceEventTest.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Entity\UserPreference;
|
||||
use App\Event\UserPreferenceEvent;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Event\UserPreferenceEvent
|
||||
*/
|
||||
class UserPreferenceEventTest extends TestCase
|
||||
{
|
||||
public function testGetterAndSetter()
|
||||
{
|
||||
$user = new User();
|
||||
$user->setAlias('foo');
|
||||
$pref = new UserPreference();
|
||||
$pref->setName('foo')->setValue('bar');
|
||||
|
||||
$sut = new UserPreferenceEvent($user, []);
|
||||
|
||||
$this->assertEquals($user, $sut->getUser());
|
||||
$this->assertEquals([], $sut->getPreferences());
|
||||
|
||||
$sut->addUserPreference($pref);
|
||||
|
||||
$this->assertEquals([$pref], $sut->getPreferences());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testDuplicatePreferenceThrowsException()
|
||||
{
|
||||
$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);
|
||||
$sut->addUserPreference($pref2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user