mirror of
https://github.com/kevinpapst/kimai2.git
synced 2025-04-30 07:20:11 +00:00

- added "today" as selector in date-range dropdown - added feature to prevent auto-select of dropdowns with only one entry - added hint that no changes were detected in batch update - added negative invoice sums are possible (e.g. for credit notes) - fix project list is expanded after submission - fix invalid date parsing causes 500 - fix: prevent auto-select of activities in export and invoice form (in case only one global activity exists) - fix team assignments for customer and project were not saved (using API now) - fix form fieldset with legend styling (e.g. team project assignment) - fix required meta-field were forced to have a value in batch update - fix tomselect meta-field was not disabled in batch update - fix unset internal rate is shown as 0 - fix one minute rounding problem in duration-only mode with "now" being default time - fix column width and label for duration-only mode - tech debt: cleanup invoice template (remove invoice layout) - tech debt: reorder for simpler comparison with invoice form - possible BC for devs: remove unused methods from form trait - bump composer packages (includes new translations for auth screens)
158 lines
5.8 KiB
PHP
158 lines
5.8 KiB
PHP
<?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\Entity\Team;
|
|
use App\Entity\User;
|
|
use App\Tests\DataFixtures\TeamFixtures;
|
|
use Symfony\Component\HttpKernel\HttpKernelBrowser;
|
|
|
|
/**
|
|
* @group integration
|
|
*/
|
|
class TeamControllerTest extends ControllerBaseTest
|
|
{
|
|
public function testIsSecure(): void
|
|
{
|
|
$this->assertUrlIsSecured('/admin/teams/');
|
|
}
|
|
|
|
public function testIsSecureForRole(): void
|
|
{
|
|
$this->assertUrlIsSecuredForRole(User::ROLE_TEAMLEAD, '/admin/teams/');
|
|
}
|
|
|
|
public function testIndexAction(): void
|
|
{
|
|
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
|
$em = $this->getEntityManager();
|
|
$fixture = new TeamFixtures();
|
|
$fixture->setAmount(5);
|
|
$this->importFixture($fixture);
|
|
|
|
$this->assertAccessIsGranted($client, '/admin/teams/');
|
|
$this->assertPageActions($client, [
|
|
'create modal-ajax-form' => $this->createUrl('/admin/teams/create'),
|
|
]);
|
|
$this->assertHasDataTable($client);
|
|
$this->assertDataTableRowCount($client, 'datatable_admin_teams', 6);
|
|
}
|
|
|
|
public function testIndexActionWithSearchTermQuery(): void
|
|
{
|
|
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
|
$fixture = new TeamFixtures();
|
|
$fixture->setAmount(5);
|
|
$fixture->setCallback(function (Team $team) {
|
|
$team->setName($team->getName() . '- fantastic team with foooo bar magic');
|
|
});
|
|
$this->importFixture($fixture);
|
|
|
|
$this->assertAccessIsGranted($client, '/admin/teams/');
|
|
|
|
$form = $client->getCrawler()->filter('form.searchform')->form();
|
|
$client->submit($form, [
|
|
'searchTerm' => 'foo',
|
|
]);
|
|
|
|
$this->assertTrue($client->getResponse()->isSuccessful());
|
|
$this->assertHasDataTable($client);
|
|
$this->assertDataTableRowCount($client, 'datatable_admin_teams', 5);
|
|
}
|
|
|
|
public function testCreateAction(): void
|
|
{
|
|
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
|
$this->assertAccessIsGranted($client, '/admin/teams/create');
|
|
$form = $client->getCrawler()->filter('form[name=team_edit_form]')->form();
|
|
|
|
$this->assertEquals('', $form->get('team_edit_form[name]')->getValue());
|
|
|
|
$values = $form->getPhpValues();
|
|
$values['team_edit_form']['name'] = 'Test Team' . uniqid();
|
|
$values['team_edit_form']['members'][0]['user'] = 5;
|
|
$values['team_edit_form']['members'][0]['teamlead'] = 1;
|
|
$client->request($form->getMethod(), $form->getUri(), $values, $form->getPhpFiles());
|
|
|
|
$location = $this->assertIsModalRedirect($client, '/edit');
|
|
$this->requestPure($client, $location);
|
|
|
|
$this->assertHasFlashSuccess($client);
|
|
$this->assertHasCustomerAndProjectPermissionBoxes($client);
|
|
}
|
|
|
|
protected function assertHasCustomerAndProjectPermissionBoxes(HttpKernelBrowser $client): void
|
|
{
|
|
$content = $client->getResponse()->getContent();
|
|
$this->assertStringContainsString('Grant access to customers', $content);
|
|
$this->assertStringContainsString('Grant access to projects', $content);
|
|
$this->assertEquals(1, $client->getCrawler()->filter('form[name=team_customer_form]')->count());
|
|
$this->assertEquals(1, $client->getCrawler()->filter('form[name=team_project_form]')->count());
|
|
}
|
|
|
|
public function testEditAction(): void
|
|
{
|
|
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
|
|
|
$fixture = new TeamFixtures();
|
|
$fixture->setAmount(2);
|
|
$this->importFixture($fixture);
|
|
|
|
$this->assertAccessIsGranted($client, '/admin/teams/1/edit');
|
|
$form = $client->getCrawler()->filter('form[name=team_edit_form]')->form();
|
|
|
|
$client->submit($form, [
|
|
'team_edit_form' => [
|
|
'name' => 'Test Team 2'
|
|
]
|
|
]);
|
|
$this->assertIsRedirect($client, $this->createUrl('/admin/teams/1/edit'));
|
|
$client->followRedirect();
|
|
$editForm = $client->getCrawler()->filter('form[name=team_edit_form]')->form();
|
|
$this->assertEquals('Test Team 2', $editForm->get('team_edit_form[name]')->getValue());
|
|
}
|
|
|
|
public function testEditMemberAction(): void
|
|
{
|
|
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
|
|
|
$fixture = new TeamFixtures();
|
|
$fixture->setAmount(2);
|
|
$this->importFixture($fixture);
|
|
|
|
$this->assertAccessIsGranted($client, '/admin/teams/1/edit_member');
|
|
$form = $client->getCrawler()->filter('form[name=team_edit_form]')->form();
|
|
$client->submit($form, [
|
|
'team_edit_form' => [
|
|
'name' => 'Test Team 2'
|
|
]
|
|
]);
|
|
$this->assertIsRedirect($client, $this->createUrl('/admin/teams/1/edit'));
|
|
$client->followRedirect();
|
|
$editForm = $client->getCrawler()->filter('form[name=team_edit_form]')->form();
|
|
$this->assertEquals('Test Team 2', $editForm->get('team_edit_form[name]')->getValue());
|
|
}
|
|
|
|
public function testDuplicateAction(): void
|
|
{
|
|
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
|
|
|
$this->request($client, '/admin/teams/1/duplicate');
|
|
$form = $client->getCrawler()->filter('form[name=team_edit_form]')->form();
|
|
|
|
$client->submit($form);
|
|
|
|
$location = $this->assertIsModalRedirect($client);
|
|
$this->requestPure($client, $location);
|
|
|
|
$editForm = $client->getCrawler()->filter('form[name=team_edit_form]')->form();
|
|
$this->assertEquals('Test team (1)', $editForm->get('team_edit_form[name]')->getValue());
|
|
}
|
|
}
|