0
0
Fork 0
mirror of https://github.com/kevinpapst/kimai2.git synced 2025-05-11 12:15:43 +00:00
kevinpapst_kimai2/tests/Controller/CalendarControllerTest.php

136 lines
5 KiB
PHP
Raw Normal View History

2018-07-27 20:19:56 +02:00
<?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\Controller;
use App\Configuration\SystemConfiguration;
use App\Entity\User;
2019-05-19 16:16:20 +02:00
use App\Tests\Configuration\TestConfigLoader;
use App\Tests\DataFixtures\TimesheetFixtures;
use App\Tests\Mocks\SystemConfigurationFactory;
2018-07-27 20:19:56 +02:00
/**
* @group integration
*/
2024-12-22 01:25:30 +01:00
class CalendarControllerTest extends AbstractControllerBaseTestCase
2018-07-27 20:19:56 +02:00
{
2024-02-07 23:47:25 +01:00
public function testIsSecure(): void
2018-07-27 20:19:56 +02:00
{
$this->assertUrlIsSecured('/calendar/');
}
2024-02-07 23:47:25 +01:00
public function testCalendarAction(): void
2018-07-27 20:19:56 +02:00
{
$client = $this->getClientForAuthenticatedUser();
$fixtures = new TimesheetFixtures($this->getUserByRole(), 10);
$fixtures->setStartDate(new \DateTime('-6 month'));
$this->importFixture($fixtures);
2018-07-27 20:19:56 +02:00
$this->request($client, '/calendar/');
2024-12-22 01:25:30 +01:00
self::assertTrue($client->getResponse()->isSuccessful());
2018-07-27 20:19:56 +02:00
$crawler = $client->getCrawler();
2019-05-19 16:16:20 +02:00
$calendar = $crawler->filter('div#timesheet_calendar');
2024-12-22 01:25:30 +01:00
self::assertEquals(1, $calendar->count());
$dragAndDropBoxes = $crawler->filter('div.card-body.drag-and-drop-source');
2024-12-22 01:25:30 +01:00
self::assertEquals(1, $dragAndDropBoxes->count());
2018-07-27 20:19:56 +02:00
}
2024-02-07 23:47:25 +01:00
public function testCalendarActionAsSuperAdmin(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);
$this->assertAccessIsGranted($client, '/calendar/');
}
2024-02-07 23:47:25 +01:00
public function testCalendarActionWithGoogleSource(): void
2018-07-27 20:19:56 +02:00
{
2019-05-19 16:16:20 +02:00
$loader = new TestConfigLoader([]);
$config = SystemConfigurationFactory::create($loader, $this->getDefaultSettings());
2018-07-27 20:19:56 +02:00
2019-05-19 16:16:20 +02:00
$client = $this->getClientForAuthenticatedUser();
self::getContainer()->set(SystemConfiguration::class, $config);
2019-05-19 16:16:20 +02:00
$this->request($client, '/calendar/');
$this->assertSuccessResponse($client);
2018-07-27 20:19:56 +02:00
2019-05-19 16:16:20 +02:00
$crawler = $client->getCrawler();
$calendar = $crawler->filter('div#timesheet_calendar');
2024-12-22 01:25:30 +01:00
self::assertEquals(1, $calendar->count());
2018-07-27 20:19:56 +02:00
2019-05-19 16:16:20 +02:00
$content = $client->getResponse()->getContent();
2024-12-22 01:25:30 +01:00
self::assertStringContainsString("googleCalendarId: 'de.german#holiday@group.v.calendar.google.com',", $content);
self::assertStringContainsString("name: 'holidays'", $content);
self::assertStringContainsString("googleCalendarId: 'en.german#holiday@group.v.calendar.google.com',", $content);
self::assertStringContainsString("name: 'holidays_en'", $content);
2018-08-08 23:10:45 +02:00
}
protected function getDefaultSettings(): array
2018-08-08 23:10:45 +02:00
{
2019-05-19 16:16:20 +02:00
return [
'theme' => [
'show_about' => true,
'chart' => [
'background_color' => '#3c8dbc',
'border_color' => '#3b8bba',
'grid_color' => 'rgba(0,0,0,.05)',
'height' => '200',
],
'branding' => [
'logo' => null,
'mini' => null,
'company' => null,
'title' => null,
'translation' => null,
],
'calendar' => [
'background_color' => '#d2d6de'
],
'colors_limited' => true,
'color_choices' => 'Silver|#c0c0c0,Gray|#808080,Black|#000000,Maroon|#800000,Brown|#a52a2a,Red|#ff0000,Orange|#ffa500,Gold|#ffd700,Yellow|#ffff00,Peach|#ffdab9,Khaki|#f0e68c,Olive|#808000,Lime|#00ff00,Jelly|#9acd32,Green|#008000,Teal|#008080,Aqua|#00ffff,LightBlue|#add8e6,DeepSky|#00bfff,Dodger|#1e90ff,Blue|#0000ff,Navy|#000080,Purple|#800080,Fuchsia|#ff00ff,Violet|#ee82ee,Rose|#ffe4e1,Lavender|#E6E6FA'
],
'defaults' => [
'user' => [
'language' => 'en'
],
],
'timesheet' => [
'default_begin' => '08:30:00',
'mode' => 'default'
2019-05-19 16:16:20 +02:00
],
'calendar' => [
'businessHours' => [
'days' => [2, 4, 6],
'begin' => '07:49',
'end' => '19:27'
],
'visibleHours' => [
'begin' => '07:49',
'end' => '19:27'
],
'day_limit' => 20,
'week_numbers' => false,
'slot_duration' => '00:15:00',
'google' => [
'api_key' => 'wertwertwegsdfbdf243w567fg8ihuon',
'sources' => [
'holidays' => [
'id' => 'de.german#holiday@group.v.calendar.google.com',
'color' => '#ccc',
],
'holidays_en' => [
'id' => 'en.german#holiday@group.v.calendar.google.com',
'color' => '#fff',
],
]
],
'weekends' => true,
2019-05-19 16:16:20 +02:00
],
];
2018-07-27 20:19:56 +02:00
}
}