{{ macro.avatar(user.avatar, user.username, 'profile-user-img img-responsive img-circle') }}
{{ widgets.username(user) }}
diff --git a/tests/API/ActivityControllerTest.php b/tests/API/ActivityControllerTest.php
index d0cece96..5376601a 100644
--- a/tests/API/ActivityControllerTest.php
+++ b/tests/API/ActivityControllerTest.php
@@ -221,10 +221,10 @@ class ActivityControllerTest extends APIControllerBaseTest
protected function assertStructure(array $result, $full = true)
{
- $expectedKeys = ['id', 'name', 'visible', 'project', 'hourlyRate', 'fixedRate'];
+ $expectedKeys = ['id', 'name', 'visible', 'project', 'hourlyRate', 'fixedRate', 'color'];
if ($full) {
- $expectedKeys = array_merge($expectedKeys, ['comment', 'color']);
+ $expectedKeys = array_merge($expectedKeys, ['comment']);
}
$actual = array_keys($result);
diff --git a/tests/API/CustomerControllerTest.php b/tests/API/CustomerControllerTest.php
index a7e2fb20..0c2eece7 100644
--- a/tests/API/CustomerControllerTest.php
+++ b/tests/API/CustomerControllerTest.php
@@ -164,11 +164,11 @@ class CustomerControllerTest extends APIControllerBaseTest
protected function assertStructure(array $result, $full = true)
{
- $expectedKeys = ['id', 'name', 'visible', 'hourlyRate', 'fixedRate'];
+ $expectedKeys = ['id', 'name', 'visible', 'hourlyRate', 'fixedRate', 'color'];
if ($full) {
$expectedKeys = array_merge($expectedKeys, [
- 'homepage', 'number', 'comment', 'company', 'contact', 'address', 'country', 'currency', 'phone', 'fax', 'mobile', 'email', 'timezone', 'color'
+ 'homepage', 'number', 'comment', 'company', 'contact', 'address', 'country', 'currency', 'phone', 'fax', 'mobile', 'email', 'timezone'
]);
}
diff --git a/tests/API/ProjectControllerTest.php b/tests/API/ProjectControllerTest.php
index 9ad3f562..8170a4b1 100644
--- a/tests/API/ProjectControllerTest.php
+++ b/tests/API/ProjectControllerTest.php
@@ -214,13 +214,13 @@ class ProjectControllerTest extends APIControllerBaseTest
protected function assertStructure(array $result, $full = true)
{
$expectedKeys = [
- 'id', 'name', 'visible', 'customer', 'hourlyRate', 'fixedRate'
+ 'id', 'name', 'visible', 'customer', 'hourlyRate', 'fixedRate', 'color'
];
if ($full) {
$expectedKeys = array_merge(
$expectedKeys,
- ['comment', 'budget', 'orderNumber', 'color']
+ ['comment', 'budget', 'orderNumber']
);
}
diff --git a/tests/API/TimesheetControllerTest.php b/tests/API/TimesheetControllerTest.php
index 11166ebb..33f73c3d 100644
--- a/tests/API/TimesheetControllerTest.php
+++ b/tests/API/TimesheetControllerTest.php
@@ -24,6 +24,7 @@ use Symfony\Component\HttpFoundation\Response;
class TimesheetControllerTest extends APIControllerBaseTest
{
public const DATE_FORMAT = 'Y-m-d H:i:s';
+ public const DATE_FORMAT_HTML5 = 'Y-m-d\TH:i:s';
public function setUp()
{
@@ -64,6 +65,19 @@ class TimesheetControllerTest extends APIControllerBaseTest
$this->assertDefaultStructure($result[0], false);
}
+ public function testGetCollectionFull()
+ {
+ $client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
+ $this->assertAccessIsGranted($client, '/api/timesheets', 'GET', ['full' => 'true']);
+ $result = json_decode($client->getResponse()->getContent(), true);
+
+ $this->assertIsArray($result);
+ $this->assertNotEmpty($result);
+ $this->assertEquals(10, count($result));
+ $this->assertDefaultStructure($result[0], false);
+ $this->assertHasSubresources($result[0]);
+ }
+
public function testGetCollectionForOtherUser()
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_TEAMLEAD);
@@ -141,10 +155,11 @@ class TimesheetControllerTest extends APIControllerBaseTest
'order' => 'DESC',
'orderBy' => 'rate',
'active' => 0,
- 'begin' => $begin->format('Y-m-d H:i:s'),
- 'end' => $end->format('Y-m-d H:i:s'),
+ 'begin' => $begin->format(self::DATE_FORMAT_HTML5),
+ 'end' => $end->format(self::DATE_FORMAT_HTML5),
'exported' => 0,
];
+
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->assertAccessIsGranted($client, '/api/timesheets', 'GET', $query);
$result = json_decode($client->getResponse()->getContent(), true);
@@ -178,10 +193,11 @@ class TimesheetControllerTest extends APIControllerBaseTest
$query = [
'page' => 1,
'size' => 50,
- 'begin' => $begin->format('Y-m-d H:i:s'),
- 'end' => $end->format('Y-m-d H:i:s'),
+ 'begin' => $begin->format(self::DATE_FORMAT_HTML5),
+ 'end' => $end->format(self::DATE_FORMAT_HTML5),
'exported' => 1,
];
+
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->assertAccessIsGranted($client, '/api/timesheets', 'GET', $query);
$result = json_decode($client->getResponse()->getContent(), true);
@@ -194,10 +210,11 @@ class TimesheetControllerTest extends APIControllerBaseTest
$query = [
'page' => 1,
'size' => 50,
- 'begin' => $begin->format('Y-m-d H:i:s'),
- 'end' => $end->format('Y-m-d H:i:s'),
+ 'begin' => $begin->format(self::DATE_FORMAT_HTML5),
+ 'end' => $end->format(self::DATE_FORMAT_HTML5),
'exported' => 0,
];
+
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->assertAccessIsGranted($client, '/api/timesheets', 'GET', $query);
$result = json_decode($client->getResponse()->getContent(), true);
@@ -210,8 +227,8 @@ class TimesheetControllerTest extends APIControllerBaseTest
$query = [
'page' => 1,
'size' => 50,
- 'begin' => $begin->format('Y-m-d H:i:s'),
- 'end' => $end->format('Y-m-d H:i:s'),
+ 'begin' => $begin->format(self::DATE_FORMAT_HTML5),
+ 'end' => $end->format(self::DATE_FORMAT_HTML5),
];
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->assertAccessIsGranted($client, '/api/timesheets', 'GET', $query);
@@ -482,7 +499,7 @@ class TimesheetControllerTest extends APIControllerBaseTest
$query = [
'user' => 'all',
'size' => 2,
- 'begin' => $start->format(self::DATE_FORMAT),
+ 'begin' => $start->format(self::DATE_FORMAT_HTML5),
];
$this->assertAccessIsGranted($client, '/api/timesheets/recent', 'GET', $query);
diff --git a/tests/Calendar/ConfigTest.php b/tests/Calendar/ConfigTest.php
deleted file mode 100644
index 076df8d8..00000000
--- a/tests/Calendar/ConfigTest.php
+++ /dev/null
@@ -1,40 +0,0 @@
- [
- 'days' => [0, 99, 127],
- 'begin' => '07:49',
- 'end' => '19:27'
- ],
- 'day_limit' => 20,
- 'week_numbers' => false,
- ];
-
- $sut = new Config($config);
-
- $this->assertEquals([0, 99, 127], $sut->getBusinessDays());
- $this->assertEquals('07:49', $sut->getBusinessTimeBegin());
- $this->assertEquals('19:27', $sut->getBusinessTimeEnd());
- $this->assertEquals(20, $sut->getDayLimit());
- $this->assertFalse($sut->isShowWeekNumbers());
- }
-}
diff --git a/tests/Calendar/ServiceTest.php b/tests/Calendar/ServiceTest.php
deleted file mode 100644
index 1c3e8ed9..00000000
--- a/tests/Calendar/ServiceTest.php
+++ /dev/null
@@ -1,64 +0,0 @@
- [
- 'days' => [2, 4, 6],
- 'begin' => '07:49',
- 'end' => '19:27'
- ],
- 'day_limit' => 20,
- 'week_numbers' => false,
- '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',
- ],
- ]
- ]
- ];
-
- $sut = new Service($config);
-
- $config = $sut->getConfig();
- $this->assertInstanceOf(Config::class, $config);
- $this->assertEquals([2, 4, 6], $config->getBusinessDays());
-
- $google = $sut->getGoogle();
- $this->assertInstanceOf(Google::class, $google);
- $this->assertEquals('wertwertwegsdfbdf243w567fg8ihuon', $google->getApiKey());
-
- $sources = $google->getSources();
- $this->assertEquals(2, count($sources));
- $this->assertEquals('holidays', $sources[0]->getId());
- $this->assertEquals('#ccc', $sources[0]->getColor());
- $this->assertEquals('holidays_en', $sources[1]->getId());
- $this->assertEquals('#fff', $sources[1]->getColor());
- }
-}
diff --git a/tests/Calendar/TimesheetEntityTest.php b/tests/Calendar/TimesheetEntityTest.php
deleted file mode 100644
index 1e77d6a2..00000000
--- a/tests/Calendar/TimesheetEntityTest.php
+++ /dev/null
@@ -1,87 +0,0 @@
-setName('activity');
-
- $customer = new Customer();
- $customer->setName('customer');
-
- $project = new Project();
- $project->setName('project');
- $project->setCustomer($customer);
-
- $timesheet = new Timesheet();
- $timesheet->setActivity($activity);
- $timesheet->setProject($project);
- $timesheet->addTag((new Tag())->setName('foo'));
- $timesheet->addTag((new Tag())->setName('bar'));
-
- $sut = new TimesheetEntity($timesheet);
-
- $this->assertEquals('customer', $sut->getCustomer());
- $this->assertEquals('project', $sut->getProject());
- $this->assertEquals('activity', $sut->getTitle());
- $this->assertEquals('foo, bar', $sut->getTags());
-
- $sut->setId(13);
- $this->assertEquals(13, $sut->getId());
-
- $date = new \DateTime('-13 hours');
- $sut->setStart($date);
- $this->assertEquals($date, $sut->getStart());
-
- $date = new \DateTime('-3 hours');
- $sut->setEnd($date);
- $this->assertEquals($date, $sut->getEnd());
-
- $sut->setTitle('sdfsdf');
- $this->assertEquals('sdfsdf', $sut->getTitle());
-
- $sut->setCustomer('aaaaaaaa');
- $this->assertEquals('aaaaaaaa', $sut->getCustomer());
-
- $sut->setProject('bbbbbbbbbb');
- $this->assertEquals('bbbbbbbbbb', $sut->getProject());
-
- $sut->setActivity('cccccccc');
- $this->assertEquals('cccccccc', $sut->getActivity());
-
- $sut->setTags('hello, world');
- $this->assertEquals('hello, world', $sut->getTags());
-
- $this->assertNull($sut->getBorderColor());
- $sut->setBorderColor('#cccccc');
- $this->assertEquals('#cccccc', $sut->getBorderColor());
-
- $this->assertNull($sut->getBackgroundColor());
- $sut->setBackgroundColor('#ffffff');
- $this->assertEquals('#ffffff', $sut->getBackgroundColor());
-
- $sut->setDescription('foo-bar');
- $this->assertEquals('foo-bar', $sut->getDescription());
- }
-}
diff --git a/tests/Command/RunCodestyleCommandTest.php b/tests/Command/RunCodestyleCommandTest.php
index 5fedccf0..835a1af7 100644
--- a/tests/Command/RunCodestyleCommandTest.php
+++ b/tests/Command/RunCodestyleCommandTest.php
@@ -16,7 +16,9 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\CommandTester;
/**
- * @coversDefaultClass \App\Command\RunCodestyleCommand
+ * @covers \App\Command\RunCodestyleCommand
+ * @covers \App\Command\BashExecutor
+ * @covers \App\Command\BashResult
* @group integration
*/
class RunCodestyleCommandTest extends KernelTestCase
@@ -47,7 +49,7 @@ class RunCodestyleCommandTest extends KernelTestCase
public function testSuccessCommandNoOptions()
{
$command = $this->assertSuccessCommand([]);
- $this->assertStringStartsWith('/vendor/bin/php-cs-fixer fix --dry-run --verbose --show-progress=none --format=txt', $command);
+ $this->assertStringStartsWith('/vendor/bin/php-cs-fixer fix --dry-run --verbose --show-progress=none', $command);
}
public function testSuccessCommandFix()
@@ -56,16 +58,15 @@ class RunCodestyleCommandTest extends KernelTestCase
$this->assertStringStartsWith('/vendor/bin/php-cs-fixer fix', $command);
}
- public function testSuccessCommandCheckstyle()
+ public function testSuccessCommand()
{
- $command = $this->assertSuccessCommand(['--checkstyle' => 'phpcs.txt']);
- $this->assertStringStartsWith('/vendor/bin/php-cs-fixer fix --dry-run --verbose --show-progress=none > ', $command);
- $this->assertStringEndsWith('phpcs.txt', $command);
+ $command = $this->assertSuccessCommand([]);
+ $this->assertStringStartsWith('/vendor/bin/php-cs-fixer fix --dry-run --verbose --show-progress=none', $command);
}
protected function assertSuccessCommand(array $options)
{
- $result = new BashResult(0, 'FooBar');
+ $result = new BashResult(0);
$this->executor->setResult($result);
$command = $this->application->find('kimai:codestyle');
@@ -74,7 +75,6 @@ class RunCodestyleCommandTest extends KernelTestCase
$commandTester->execute($inputs);
$output = $commandTester->getDisplay();
- $this->assertContains('FooBar', $output);
$this->assertContains('[OK] All source files have proper code styles', $output);
return $this->executor->getCommand();
@@ -82,7 +82,7 @@ class RunCodestyleCommandTest extends KernelTestCase
public function testFailureCommand()
{
- $result = new BashResult(1, 'BarFoo');
+ $result = new BashResult(1);
$this->executor->setResult($result);
$command = $this->application->find('kimai:codestyle');
@@ -91,7 +91,6 @@ class RunCodestyleCommandTest extends KernelTestCase
$commandTester->execute($inputs);
$output = $commandTester->getDisplay();
- $this->assertContains('BarFoo', $output);
- $this->assertContains('[ERROR] Found problems while checking your code styles', $output);
+ $this->assertContains('[ERROR] Found violations while checking code styles', $output);
}
}
diff --git a/tests/Command/RunIntegrationTestsCommandTest.php b/tests/Command/RunIntegrationTestsCommandTest.php
index c62199c6..2ca70b05 100644
--- a/tests/Command/RunIntegrationTestsCommandTest.php
+++ b/tests/Command/RunIntegrationTestsCommandTest.php
@@ -15,7 +15,9 @@ use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
/**
- * @coversDefaultClass \App\Command\RunIntegrationTestsCommand
+ * @covers \App\Command\RunIntegrationTestsCommand
+ * @covers \App\Command\BashExecutor
+ * @covers \App\Command\BashResult
* @group integration
*/
class RunIntegrationTestsCommandTest extends RunUnitTestsCommandTest
@@ -45,7 +47,7 @@ class RunIntegrationTestsCommandTest extends RunUnitTestsCommandTest
public function testSuccessCommand()
{
- $result = new BashResult(0, 'FooBar');
+ $result = new BashResult(0);
$this->executor->setResult($result);
$command = $this->application->find('kimai:test-integration');
@@ -54,16 +56,15 @@ class RunIntegrationTestsCommandTest extends RunUnitTestsCommandTest
$commandTester->execute($inputs);
$output = $commandTester->getDisplay();
- $this->assertContains('FooBar', $output);
$this->assertContains('[OK] All tests were successful', $output);
- $this->assertStringStartsWith('/bin/phpunit --group integration', $this->executor->getCommand());
+ $this->assertStringStartsWith('/vendor/bin/phpunit --group integration', $this->executor->getCommand());
$this->assertContains($this->directory, $this->executor->getCommand());
}
public function testFailureCommand()
{
- $result = new BashResult(1, 'BarFoo');
+ $result = new BashResult(1);
$this->executor->setResult($result);
$command = $this->application->find('kimai:test-integration');
@@ -72,10 +73,9 @@ class RunIntegrationTestsCommandTest extends RunUnitTestsCommandTest
$commandTester->execute($inputs);
$output = $commandTester->getDisplay();
- $this->assertContains('BarFoo', $output);
$this->assertContains('[ERROR] Found problems while running tests', $output);
- $this->assertStringStartsWith('/bin/phpunit --group integration', $this->executor->getCommand());
+ $this->assertStringStartsWith('/vendor/bin/phpunit --group integration', $this->executor->getCommand());
$this->assertContains($this->directory, $this->executor->getCommand());
}
}
diff --git a/tests/Command/RunUnitTestsCommandTest.php b/tests/Command/RunUnitTestsCommandTest.php
index 5df815a9..168849b9 100644
--- a/tests/Command/RunUnitTestsCommandTest.php
+++ b/tests/Command/RunUnitTestsCommandTest.php
@@ -16,7 +16,9 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\CommandTester;
/**
- * @coversDefaultClass \App\Command\RunUnitTestsCommand
+ * @covers \App\Command\RunUnitTestsCommand
+ * @covers \App\Command\BashExecutor
+ * @covers \App\Command\BashResult
* @group integration
*/
class RunUnitTestsCommandTest extends KernelTestCase
@@ -46,7 +48,7 @@ class RunUnitTestsCommandTest extends KernelTestCase
public function testSuccessCommand()
{
- $result = new BashResult(0, 'FooBar');
+ $result = new BashResult(0);
$this->executor->setResult($result);
$command = $this->application->find('kimai:test-unit');
@@ -55,16 +57,15 @@ class RunUnitTestsCommandTest extends KernelTestCase
$commandTester->execute($inputs);
$output = $commandTester->getDisplay();
- $this->assertContains('FooBar', $output);
$this->assertContains('[OK] All tests were successful', $output);
- $this->assertStringStartsWith('/bin/phpunit --exclude-group integration', $this->executor->getCommand());
+ $this->assertStringStartsWith('/vendor/bin/phpunit --exclude-group integration', $this->executor->getCommand());
$this->assertContains($this->directory, $this->executor->getCommand());
}
public function testFailureCommand()
{
- $result = new BashResult(1, 'BarFoo');
+ $result = new BashResult(1);
$this->executor->setResult($result);
$command = $this->application->find('kimai:test-unit');
@@ -73,10 +74,9 @@ class RunUnitTestsCommandTest extends KernelTestCase
$commandTester->execute($inputs);
$output = $commandTester->getDisplay();
- $this->assertContains('BarFoo', $output);
$this->assertContains('[ERROR] Found problems while running tests', $output);
- $this->assertStringStartsWith('/bin/phpunit --exclude-group integration', $this->executor->getCommand());
+ $this->assertStringStartsWith('/vendor/bin/phpunit --exclude-group integration', $this->executor->getCommand());
$this->assertContains($this->directory, $this->executor->getCommand());
}
}
diff --git a/tests/Command/VersionCommandTest.php b/tests/Command/VersionCommandTest.php
index 229b5efa..0c1a0c6d 100644
--- a/tests/Command/VersionCommandTest.php
+++ b/tests/Command/VersionCommandTest.php
@@ -16,7 +16,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\CommandTester;
/**
- * @coversDefaultClass \App\Command\VersionCommand
+ * @covers \App\Command\VersionCommand
* @group integration
*/
class VersionCommandTest extends KernelTestCase
diff --git a/tests/Configuration/CalendarConfigurationTest.php b/tests/Configuration/CalendarConfigurationTest.php
new file mode 100644
index 00000000..6ce70279
--- /dev/null
+++ b/tests/Configuration/CalendarConfigurationTest.php
@@ -0,0 +1,82 @@
+ [
+ 'days' => [2, 4, 6],
+ 'begin' => '07:49',
+ 'end' => '19:27'
+ ],
+ 'day_limit' => 20,
+ 'week_numbers' => false,
+ '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,
+ ];
+ }
+
+ public function testPrefix()
+ {
+ $sut = $this->getSut($this->getDefaultSettings(), []);
+ $this->assertEquals('calendar', $sut->getPrefix());
+ }
+
+ public function testConfigs()
+ {
+ $sut = $this->getSut($this->getDefaultSettings(), []);
+ $this->assertEquals([2, 4, 6], $sut->getBusinessDays());
+ $this->assertEquals('07:49', $sut->getBusinessTimeBegin());
+ $this->assertEquals('19:27', $sut->getBusinessTimeEnd());
+ $this->assertEquals(20, $sut->getDayLimit());
+ $this->assertFalse($sut->isShowWeekNumbers());
+
+ $this->assertEquals('wertwertwegsdfbdf243w567fg8ihuon', $sut->getGoogleApiKey());
+ $sources = $sut->getGoogleSources();
+ $this->assertEquals(2, count($sources));
+ }
+}
diff --git a/tests/Controller/CalendarControllerTest.php b/tests/Controller/CalendarControllerTest.php
index 85e8cfd3..c9b33eab 100644
--- a/tests/Controller/CalendarControllerTest.php
+++ b/tests/Controller/CalendarControllerTest.php
@@ -9,8 +9,8 @@
namespace App\Tests\Controller;
-use App\Entity\User;
-use App\Tests\DataFixtures\TimesheetFixtures;
+use App\Configuration\CalendarConfiguration;
+use App\Tests\Configuration\TestConfigLoader;
/**
* @coversDefaultClass \App\Controller\CalendarController
@@ -30,69 +30,59 @@ class CalendarControllerTest extends ControllerBaseTest
$this->assertTrue($client->getResponse()->isSuccessful());
$crawler = $client->getCrawler();
- $calendar = $crawler->filter('div#calendar');
+ $calendar = $crawler->filter('div#timesheet_calendar');
$this->assertEquals(1, $calendar->count());
}
- public function testCalendarEntriesAction()
+ public function testCalendarActionWithGoogleSource()
{
- $client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
- $em = $client->getContainer()->get('doctrine.orm.entity_manager');
-
- $fixture = new TimesheetFixtures();
- $fixture->setAmount(10);
- $fixture->setUser($this->getUserByRole($em, User::ROLE_USER));
- $fixture->setStartDate('2017-05-01');
- $this->importFixture($em, $fixture);
-
- $this->request($client, '/calendar/user');
- $response = $client->getResponse();
- $this->assertTrue($response->isSuccessful());
- $json = json_decode($response->getContent(), true);
- $this->assertIsArray($json);
- $this->assertEmpty($json);
- }
-
- public function testCalendarEntriesActionWithStartAndEndDate()
- {
- $client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
- $em = $client->getContainer()->get('doctrine.orm.entity_manager');
-
- $fixture = new TimesheetFixtures();
- $fixture->setAmount(10);
- $fixture->setUser($this->getUserByRole($em, User::ROLE_USER));
- $fixture->setStartDate('2017-05-01');
- $this->importFixture($em, $fixture);
+ $loader = new TestConfigLoader([]);
+ $config = new CalendarConfiguration($loader, $this->getDefaultSettings());
$client = $this->getClientForAuthenticatedUser();
- $this->request($client, '/calendar/user?start=2017-05-01&end=2017-05-30');
- $response = $client->getResponse();
- $this->assertTrue($response->isSuccessful());
- $json = json_decode($response->getContent(), true);
- $this->assertIsArray($json);
- $this->assertNotEmpty($json);
- $this->assertEquals(10, count($json));
- foreach ($json as $result) {
- $this->assertIsArray($result);
- $this->assertCalendarStructure($result);
- }
+ $client->getContainer()->set(CalendarConfiguration::class, $config);
+ $this->request($client, '/calendar/');
+ $this->assertTrue($client->getResponse()->isSuccessful());
+
+ $crawler = $client->getCrawler();
+ $calendar = $crawler->filter('div#timesheet_calendar');
+ $this->assertEquals(1, $calendar->count());
+
+ $content = $client->getResponse()->getContent();
+ $this->assertContains("googleCalendarId: 'de.german#holiday@group.v.calendar.google.com',", $content);
+ $this->assertContains("name: 'holidays'", $content);
+ $this->assertContains("googleCalendarId: 'en.german#holiday@group.v.calendar.google.com',", $content);
+ $this->assertContains("name: 'holidays_en'", $content);
}
- protected function assertCalendarStructure(array $result)
+ protected function getDefaultSettings()
{
- $this->assertArrayHasKey('id', $result);
- $this->assertArrayHasKey('start', $result);
- $this->assertArrayHasKey('title', $result);
- $this->assertArrayHasKey('description', $result);
- $this->assertArrayHasKey('customer', $result);
- $this->assertArrayHasKey('project', $result);
- $this->assertArrayHasKey('activity', $result);
- $this->assertArrayHasKey('borderColor', $result);
- $this->assertArrayHasKey('backgroundColor', $result);
-
- if (isset($result['end'])) {
- $this->assertNull($result['borderColor']);
- $this->assertNull($result['backgroundColor']);
- }
+ return [
+ 'businessHours' => [
+ 'days' => [2, 4, 6],
+ 'begin' => '07:49',
+ 'end' => '19:27'
+ ],
+ 'visibleHours' => [
+ 'begin' => '07:49',
+ 'end' => '19:27'
+ ],
+ 'day_limit' => 20,
+ 'week_numbers' => false,
+ '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,
+ ];
}
}
diff --git a/tests/Controller/SystemConfigurationControllerTest.php b/tests/Controller/SystemConfigurationControllerTest.php
index 17db0dda..add9a8a8 100644
--- a/tests/Controller/SystemConfigurationControllerTest.php
+++ b/tests/Controller/SystemConfigurationControllerTest.php
@@ -49,9 +49,10 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
public function getTestDataForms()
{
return [
- ['#system_configuration_form_timesheet', $this->createUrl('/admin/system-config/timesheet')],
- ['#system_configuration_form_form_customer', $this->createUrl('/admin/system-config/customer')],
- ['#system_configuration_form_theme', $this->createUrl('/admin/system-config/theme')],
+ ['form[name=system_configuration_form_timesheet]', $this->createUrl('/admin/system-config/update/timesheet')],
+ ['form[name=system_configuration_form_form_customer]', $this->createUrl('/admin/system-config/update/form_customer')],
+ ['form[name=system_configuration_form_theme]', $this->createUrl('/admin/system-config/update/theme')],
+ ['form[name=system_configuration_form_calendar]', $this->createUrl('/admin/system-config/update/calendar')],
];
}
@@ -64,12 +65,12 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
$this->assertEquals(false, $configService->find('timesheet.markdown_content'));
$this->assertEquals('default', $configService->find('timesheet.mode'));
$this->assertEquals(true, $configService->find('timesheet.rules.allow_future_times'));
- $this->assertEquals(3, $configService->find('timesheet.active_entries.hard_limit'));
+ $this->assertEquals(1, $configService->find('timesheet.active_entries.hard_limit'));
$this->assertEquals(1, $configService->find('timesheet.active_entries.soft_limit'));
- $form = $client->getCrawler()->filter('#system_configuration_form_timesheet')->form();
+ $form = $client->getCrawler()->filter('form[name=system_configuration_form_timesheet]')->form();
$client->submit($form, [
- 'system_configuration_form' => [
+ 'system_configuration_form_timesheet' => [
'configuration' => [
['name' => 'timesheet.mode', 'value' => 'duration_only'],
['name' => 'timesheet.markdown_content', 'value' => 1],
@@ -98,9 +99,9 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
$this->assertFormHasValidationError(
User::ROLE_SUPER_ADMIN,
'/admin/system-config/',
- '#system_configuration_form_timesheet',
+ 'form[name=system_configuration_form_timesheet]',
[
- 'system_configuration_form' => [
+ 'system_configuration_form_timesheet' => [
'configuration' => [
['name' => 'timesheet.mode', 'value' => 'foo'],
['name' => 'timesheet.markdown_content', 'value' => 1],
@@ -111,9 +112,9 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
]
],
[
- '#system_configuration_form_configuration_0_value', // mode
- '#system_configuration_form_configuration_3_value', // hard_limit
- '#system_configuration_form_configuration_4_value', // soft_limit
+ '#system_configuration_form_timesheet_configuration_0_value', // mode
+ '#system_configuration_form_timesheet_configuration_3_value', // hard_limit
+ '#system_configuration_form_timesheet_configuration_4_value', // soft_limit
],
true
);
@@ -129,9 +130,9 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
$this->assertEquals('DE', $configService->find('defaults.customer.country'));
$this->assertEquals('EUR', $configService->find('defaults.customer.currency'));
- $form = $client->getCrawler()->filter('#system_configuration_form_form_customer')->form();
+ $form = $client->getCrawler()->filter('form[name=system_configuration_form_form_customer]')->form();
$client->submit($form, [
- 'system_configuration_form' => [
+ 'system_configuration_form_form_customer' => [
'configuration' => [
['name' => 'defaults.customer.timezone', 'value' => 'Atlantic/Canary'],
['name' => 'defaults.customer.country', 'value' => 'BB'],
@@ -156,9 +157,9 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
$this->assertFormHasValidationError(
User::ROLE_SUPER_ADMIN,
'/admin/system-config/',
- '#system_configuration_form_form_customer',
+ 'form[name=system_configuration_form_form_customer]',
[
- 'system_configuration_form' => [
+ 'system_configuration_form_form_customer' => [
'configuration' => [
['name' => 'defaults.customer.timezone', 'value' => 'XX'],
['name' => 'defaults.customer.country', 'value' => 1],
@@ -167,9 +168,124 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
]
],
[
- '#system_configuration_form_configuration_0_value',
- '#system_configuration_form_configuration_1_value',
- '#system_configuration_form_configuration_2_value',
+ '#system_configuration_form_form_customer_configuration_0_value',
+ '#system_configuration_form_form_customer_configuration_1_value',
+ '#system_configuration_form_form_customer_configuration_2_value',
+ ],
+ true
+ );
+ }
+
+ public function testUpdateThemeConfig()
+ {
+ $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);
+ $this->assertAccessIsGranted($client, '/admin/system-config/');
+
+ $configService = $client->getContainer()->get(SystemConfiguration::class);
+ $this->assertNull($configService->find('theme.select_type'));
+
+ $form = $client->getCrawler()->filter('form[name=system_configuration_form_theme]')->form();
+ $client->submit($form, [
+ 'system_configuration_form_theme' => [
+ 'configuration' => [
+ ['name' => 'theme.select_type', 'value' => '1'],
+ ]
+ ]
+ ]);
+
+ $this->assertIsRedirect($client, $this->createUrl('/admin/system-config/'));
+ $client->followRedirect();
+ $this->assertTrue($client->getResponse()->isSuccessful());
+ $this->assertHasFlashSaveSuccess($client);
+
+ $configService = $client->getContainer()->get(SystemConfiguration::class);
+ $this->assertEquals('selectpicker', $configService->find('theme.select_type'));
+ }
+
+ public function testUpdateThemeConfigValidation()
+ {
+ $this->assertFormHasValidationError(
+ User::ROLE_SUPER_ADMIN,
+ '/admin/system-config/',
+ 'form[name=system_configuration_form_theme]',
+ [
+ 'system_configuration_form_theme' => [
+ 'configuration' => [
+ ['name' => 'theme.select_type', 'value' => 'foo'],
+ ]
+ ]
+ ],
+ [
+ '#system_configuration_form_theme_configuration_0_value',
+ ],
+ true
+ );
+ }
+
+ public function testUpdateCalendarConfig()
+ {
+ $client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);
+ $this->assertAccessIsGranted($client, '/admin/system-config/');
+
+ $configService = $client->getContainer()->get(SystemConfiguration::class);
+ $this->assertTrue($configService->find('calendar.week_numbers'));
+ $this->assertTrue($configService->find('calendar.weekends'));
+ $this->assertEquals('08:00', $configService->find('calendar.businessHours.begin'));
+ $this->assertEquals('20:00', $configService->find('calendar.businessHours.end'));
+ $this->assertEquals('00:00', $configService->find('calendar.visibleHours.begin'));
+ $this->assertEquals('24:00', $configService->find('calendar.visibleHours.end'));
+
+ $form = $client->getCrawler()->filter('form[name=system_configuration_form_calendar]')->form();
+ $client->submit($form, [
+ 'system_configuration_form_calendar' => [
+ 'configuration' => [
+ ['name' => 'calendar.week_numbers', 'value' => false],
+ ['name' => 'calendar.weekends', 'value' => false],
+ ['name' => 'calendar.businessHours.begin', 'value' => '10:00'],
+ ['name' => 'calendar.businessHours.end', 'value' => '16:00'],
+ ['name' => 'calendar.visibleHours.begin', 'value' => '05:17'],
+ ['name' => 'calendar.visibleHours.end', 'value' => '21:43'],
+ ]
+ ]
+ ]);
+
+ $this->assertIsRedirect($client, $this->createUrl('/admin/system-config/'));
+ $client->followRedirect();
+ $this->assertTrue($client->getResponse()->isSuccessful());
+ $this->assertHasFlashSaveSuccess($client);
+
+ $configService = $client->getContainer()->get(SystemConfiguration::class);
+ $this->assertFalse($configService->find('calendar.week_numbers'));
+ $this->assertFalse($configService->find('calendar.weekends'));
+ $this->assertEquals('10:00', $configService->find('calendar.businessHours.begin'));
+ $this->assertEquals('16:00', $configService->find('calendar.businessHours.end'));
+ $this->assertEquals('05:17', $configService->find('calendar.visibleHours.begin'));
+ $this->assertEquals('21:43', $configService->find('calendar.visibleHours.end'));
+ }
+
+ public function testUpdateCalendarConfigValidation()
+ {
+ $this->assertFormHasValidationError(
+ User::ROLE_SUPER_ADMIN,
+ '/admin/system-config/',
+ 'form[name=system_configuration_form_calendar]',
+ [
+ 'system_configuration_form_calendar' => [
+ 'configuration' => [
+ ['name' => 'calendar.week_numbers', 'value' => 'foo'],
+ ['name' => 'calendar.weekends', 'value' => 'bar'],
+ ['name' => 'calendar.businessHours.begin', 'value' => '25:13'],
+ ['name' => 'calendar.businessHours.end', 'value' => null],
+ ['name' => 'calendar.visibleHours.begin', 'value' => 'aa:bb'],
+ ['name' => 'calendar.visibleHours.end', 'value' => ''],
+ ]
+ ]
+ ],
+ [
+ '#system_configuration_form_calendar_configuration_2_value',
+ '#system_configuration_form_calendar_configuration_3_value',
+ '#system_configuration_form_calendar_configuration_4_value',
+ '#system_configuration_form_calendar_configuration_5_value',
],
true
);
diff --git a/tests/Controller/TimesheetControllerTest.php b/tests/Controller/TimesheetControllerTest.php
index b9e7fc06..627a8502 100644
--- a/tests/Controller/TimesheetControllerTest.php
+++ b/tests/Controller/TimesheetControllerTest.php
@@ -35,7 +35,7 @@ class TimesheetControllerTest extends ControllerBaseTest
$this->assertHasNoEntriesWithFilter($client);
$result = $client->getCrawler()->filter('div.breadcrumb div.box-tools div.btn-group a.btn');
- $this->assertEquals(5, count($result));
+ $this->assertEquals(4, count($result));
foreach ($result as $item) {
$this->assertContains('btn btn-default', $item->getAttribute('class'));
diff --git a/tests/Invoice/Calculator/ActivityInvoiceCalculatorTest.php b/tests/Invoice/Calculator/ActivityInvoiceCalculatorTest.php
index d2b1ed5c..466a1246 100644
--- a/tests/Invoice/Calculator/ActivityInvoiceCalculatorTest.php
+++ b/tests/Invoice/Calculator/ActivityInvoiceCalculatorTest.php
@@ -21,6 +21,7 @@ use App\Repository\Query\InvoiceQuery;
/**
* @covers \App\Invoice\Calculator\ActivityInvoiceCalculator
+ * @covers \App\Invoice\Calculator\AbstractMergedCalculator
* @covers \App\Invoice\Calculator\AbstractCalculator
*/
class ActivityInvoiceCalculatorTest extends AbstractCalculatorTest
diff --git a/tests/Invoice/Calculator/ShortInvoiceCalculatorTest.php b/tests/Invoice/Calculator/ShortInvoiceCalculatorTest.php
index 264d5936..d0c0a885 100644
--- a/tests/Invoice/Calculator/ShortInvoiceCalculatorTest.php
+++ b/tests/Invoice/Calculator/ShortInvoiceCalculatorTest.php
@@ -21,6 +21,7 @@ use App\Repository\Query\InvoiceQuery;
/**
* @covers \App\Invoice\Calculator\ShortInvoiceCalculator
+ * @covers \App\Invoice\Calculator\AbstractMergedCalculator
* @covers \App\Invoice\Calculator\AbstractCalculator
*/
class ShortInvoiceCalculatorTest extends AbstractCalculatorTest
diff --git a/tests/Invoice/Calculator/UserInvoiceCalculatorTest.php b/tests/Invoice/Calculator/UserInvoiceCalculatorTest.php
index 60a767c4..625f4d98 100644
--- a/tests/Invoice/Calculator/UserInvoiceCalculatorTest.php
+++ b/tests/Invoice/Calculator/UserInvoiceCalculatorTest.php
@@ -21,6 +21,7 @@ use App\Repository\Query\InvoiceQuery;
/**
* @covers \App\Invoice\Calculator\UserInvoiceCalculator
+ * @covers \App\Invoice\Calculator\AbstractMergedCalculator
* @covers \App\Invoice\Calculator\AbstractCalculator
*/
class UserInvoiceCalculatorTest extends AbstractCalculatorTest
diff --git a/translations/system-configuration.de.xliff b/translations/system-configuration.de.xliff
index a6c574c1..e964b96c 100644
--- a/translations/system-configuration.de.xliff
+++ b/translations/system-configuration.de.xliff
@@ -22,6 +22,10 @@
theme
Darstellung
+
+ calendar
+ Kalender
+
label.timesheet.markdown_content
Erlaube Markdown in den Beschreibungen der erfassten Zeiten
@@ -54,6 +58,30 @@
label.theme.select_type
Art der Auswahl-Boxen in Formularen
+
+ label.calendar.week_numbers
+ Kalenderwochen anzeigen
+
+
+ label.calendar.weekends
+ Wochenenden anzeigen
+
+
+ label.calendar.businessHours.begin
+ Start der üblichen Arbeitszeit (wird optisch hervorgehoben)
+
+
+ label.calendar.businessHours.end
+ Ende der üblichen Arbeitszeit (wird optisch hervorgehoben)
+
+
+ label.calendar.visibleHours.begin
+ Start des sichtbaren Zeitbereichs
+
+
+ label.calendar.visibleHours.end
+ Ende des sichtbaren Zeitbereichs
+