mirror of
https://github.com/kevinpapst/kimai2.git
synced 2025-03-19 07:03:19 +00:00

* added sortable js library * activity in invoice is optional * added javascript widget for paginated boxes * fix activity dropdown for globals only * added timesheet service to reduce code duplication * use repository to query for teams in dropdowns * added project validator * validate project start and end against timesheet * include begin and end in dynamic form requests for projects * added timezone and language option to import flag, improve timesheet import speed * deactivate cross-timezone filter * add virtual fields to field order list * composer update * added param to ignore dates * position loader icon fixed - fixes #1330 * permission problem when creating a new project - fixes #1340 * remove dev dependencies webserver and thanks bundle * stop information leak (begin and end date) in duration mode - fixes #1307 * unify timesheet edit dialog for user and admins * fix security issue, own rates exposed to unauthorized users in multi-update dialog
74 lines
1.9 KiB
PHP
74 lines
1.9 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;
|
|
|
|
use App\DataFixtures\UserFixtures;
|
|
use App\Entity\User;
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
|
|
use Doctrine\Common\DataFixtures\Loader;
|
|
use Doctrine\ORM\EntityManager;
|
|
|
|
/**
|
|
* A trait to be used in all tests that extend the KernelTestCase.
|
|
*/
|
|
trait KernelTestTrait
|
|
{
|
|
/**
|
|
* @param EntityManager $em
|
|
* @param Fixture $fixture
|
|
*/
|
|
protected function importFixture(EntityManager $em, Fixture $fixture)
|
|
{
|
|
$loader = new Loader();
|
|
$loader->addFixture($fixture);
|
|
|
|
$executor = new ORMExecutor($em, null);
|
|
$executor->execute($loader->getFixtures(), true);
|
|
}
|
|
|
|
protected function getUserByName(EntityManager $em, string $username): ?User
|
|
{
|
|
return $em->getRepository(User::class)->findOneBy(['username' => $username]);
|
|
}
|
|
|
|
/**
|
|
* @param EntityManager $em
|
|
* @param string $role
|
|
* @return User|null
|
|
*/
|
|
protected function getUserByRole(EntityManager $em, string $role = User::ROLE_USER)
|
|
{
|
|
$name = null;
|
|
|
|
switch ($role) {
|
|
case User::ROLE_SUPER_ADMIN:
|
|
$name = UserFixtures::USERNAME_SUPER_ADMIN;
|
|
break;
|
|
|
|
case User::ROLE_ADMIN:
|
|
$name = UserFixtures::USERNAME_ADMIN;
|
|
break;
|
|
|
|
case User::ROLE_TEAMLEAD:
|
|
$name = UserFixtures::USERNAME_TEAMLEAD;
|
|
break;
|
|
|
|
case User::ROLE_USER:
|
|
$name = UserFixtures::USERNAME_USER;
|
|
break;
|
|
|
|
default:
|
|
return null;
|
|
}
|
|
|
|
return $this->getUserByName($em, $name);
|
|
}
|
|
}
|