Release 2.25 (#5109)

This commit is contained in:
Kevin Papst
2024-11-21 22:44:49 +01:00
committed by GitHub
parent 49eb7068c9
commit 0c26a2678e
261 changed files with 6431 additions and 7426 deletions

View File

@@ -13,6 +13,7 @@ use App\Command\ActivateUserCommand;
use App\Entity\User;
use App\Repository\UserRepository;
use App\User\UserService;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Exception\RuntimeException;
@@ -33,6 +34,7 @@ class ActivateUserCommandTest extends KernelTestCase
$this->application = new Application($kernel);
$container = self::$kernel->getContainer();
/** @var UserService $userService */
$userService = $container->get(UserService::class);
$this->application->add(new ActivateUserCommand($userService));
@@ -71,8 +73,10 @@ class ActivateUserCommandTest extends KernelTestCase
$this->assertStringContainsString('[OK] User "chris_user" has been activated.', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
$doctrine = $container->get('doctrine');
/** @var UserRepository $userRepository */
$userRepository = $container->get('doctrine')->getRepository(User::class);
$userRepository = $doctrine->getRepository(User::class);
$user = $userRepository->loadUserByIdentifier('chris_user');
self::assertInstanceOf(User::class, $user);
self::assertTrue($user->isEnabled());

View File

@@ -13,6 +13,7 @@ use App\Command\ChangePasswordCommand;
use App\Entity\User;
use App\Repository\UserRepository;
use App\User\UserService;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Exception\RuntimeException;
@@ -35,6 +36,7 @@ class ChangePasswordCommandTest extends KernelTestCase
$this->application = new Application($kernel);
$container = self::$kernel->getContainer();
/** @var UserService $userService */
$userService = $container->get(UserService::class);
$this->application->add(new ChangePasswordCommand($userService));
@@ -86,8 +88,10 @@ class ChangePasswordCommandTest extends KernelTestCase
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[OK] Changed password for user "john_user".', $output);
/** @var Registry $doctrine */
$doctrine = self::getContainer()->get('doctrine');
/** @var UserRepository $userRepository */
$userRepository = self::getContainer()->get('doctrine')->getRepository(User::class);
$userRepository = $doctrine->getRepository(User::class);
$user = $userRepository->loadUserByIdentifier('john_user');
self::assertInstanceOf(User::class, $user);

View File

@@ -13,6 +13,7 @@ use App\Command\CreateUserCommand;
use App\Entity\User;
use App\Repository\UserRepository;
use App\User\UserService;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\CommandTester;
@@ -31,10 +32,9 @@ class CreateUserCommandTest extends KernelTestCase
$kernel = self::bootKernel();
$this->application = new Application($kernel);
$container = self::$kernel->getContainer();
$this->application->add(new CreateUserCommand(
$container->get(UserService::class),
));
/** @var UserService $userService */
$userService = $container->get(UserService::class);
$this->application->add(new CreateUserCommand($userService));
}
public function testCreateUserFailsForShortPassword(): void
@@ -53,11 +53,12 @@ class CreateUserCommandTest extends KernelTestCase
$this->assertStringContainsString('[OK] Success! Created user: MyTestUser', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
$doctrine = $container->get('doctrine');
/** @var UserRepository $userRepository */
$userRepository = $container->get('doctrine')->getRepository(User::class);
$userRepository = $doctrine->getRepository(User::class);
$user = $userRepository->loadUserByIdentifier('MyTestUser');
self::assertInstanceOf(User::class, $user);
self::assertNotNull($user);
}
protected function createUser($username, $email, $role, $password): CommandTester

View File

@@ -13,6 +13,7 @@ use App\Command\DeactivateUserCommand;
use App\Entity\User;
use App\Repository\UserRepository;
use App\User\UserService;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Exception\RuntimeException;
@@ -32,7 +33,7 @@ class DeactivateUserCommandTest extends KernelTestCase
$kernel = self::bootKernel();
$this->application = new Application($kernel);
$container = self::$kernel->getContainer();
/** @var UserService $userService */
$userService = $container->get(UserService::class);
$this->application->add(new DeactivateUserCommand($userService));
@@ -71,8 +72,10 @@ class DeactivateUserCommandTest extends KernelTestCase
$this->assertStringContainsString('[OK] User "john_user" has been deactivated.', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
$doctrine = $container->get('doctrine');
/** @var UserRepository $userRepository */
$userRepository = $container->get('doctrine')->getRepository(User::class);
$userRepository = $doctrine->getRepository(User::class);
$user = $userRepository->loadUserByIdentifier('john_user');
self::assertInstanceOf(User::class, $user);
self::assertFalse($user->isEnabled());

View File

@@ -13,6 +13,7 @@ use App\Command\DemoteUserCommand;
use App\Entity\User;
use App\Repository\UserRepository;
use App\User\UserService;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Exception\RuntimeException;
@@ -34,6 +35,7 @@ class DemoteUserCommandTest extends KernelTestCase
$this->application = new Application($kernel);
$container = self::$kernel->getContainer();
/** @var UserService $userService */
$userService = $container->get(UserService::class);
$this->application->add(new DemoteUserCommand($userService));
@@ -80,8 +82,10 @@ class DemoteUserCommandTest extends KernelTestCase
$this->assertStringContainsString('[OK] Role "ROLE_TEAMLEAD" has been removed from user "tony_teamlead".', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
$doctrine = $container->get('doctrine');
/** @var UserRepository $userRepository */
$userRepository = $container->get('doctrine')->getRepository(User::class);
$userRepository = $doctrine->getRepository(User::class);
$user = $userRepository->loadUserByIdentifier('tony_teamlead');
self::assertInstanceOf(User::class, $user);
self::assertFalse($user->hasTeamleadRole());
@@ -95,8 +99,10 @@ class DemoteUserCommandTest extends KernelTestCase
$this->assertStringContainsString('[OK] Super administrator role has been removed from the user "susan_super".', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
$doctrine = $container->get('doctrine');
/** @var UserRepository $userRepository */
$userRepository = $container->get('doctrine')->getRepository(User::class);
$userRepository = $doctrine->getRepository(User::class);
$user = $userRepository->loadUserByIdentifier('susan_super');
self::assertInstanceOf(User::class, $user);
self::assertFalse($user->isSuperAdmin());

View File

@@ -45,6 +45,9 @@ class ExportCreateCommandTest extends KernelTestCase
if (is_dir($path)) {
$files = glob($path . '*');
if ($files === false) {
return;
}
foreach ($files as $file) {
unlink($file);
}
@@ -71,12 +74,12 @@ class ExportCreateCommandTest extends KernelTestCase
$container = self::getContainer();
$application->add(new ExportCreateCommand(
$container->get(ServiceExport::class),
$container->get(CustomerRepository::class),
$container->get(ProjectRepository::class),
$container->get(TeamRepository::class),
$container->get(UserRepository::class),
$container->get(TranslatorInterface::class),
$container->get(ServiceExport::class), // @phpstan-ignore argument.type
$container->get(CustomerRepository::class), // @phpstan-ignore argument.type
$container->get(ProjectRepository::class), // @phpstan-ignore argument.type
$container->get(TeamRepository::class), // @phpstan-ignore argument.type
$container->get(UserRepository::class), // @phpstan-ignore argument.type
$container->get(TranslatorInterface::class), // @phpstan-ignore argument.type
$mailer ?? $container->get(KimaiMailer::class),
));

View File

@@ -10,6 +10,7 @@
namespace App\Tests\Command;
use App\Command\InstallCommand;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
@@ -27,9 +28,11 @@ class InstallCommandTest extends KernelTestCase
$kernel = self::bootKernel();
$this->application = new Application($kernel);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
$doctrine = $container->get('doctrine');
$this->application->add(new InstallCommand(
$container->get('doctrine')->getConnection()
$doctrine->getConnection() // @phpstan-ignore argument.type
));
}

View File

@@ -43,6 +43,9 @@ class InvoiceCreateCommandTest extends KernelTestCase
if (is_dir($path)) {
$files = glob($path . '*');
if ($files === false) {
return;
}
foreach ($files as $file) {
unlink($file);
}
@@ -64,12 +67,12 @@ class InvoiceCreateCommandTest extends KernelTestCase
$container = self::getContainer();
$this->application->add(new InvoiceCreateCommand(
$container->get(ServiceInvoice::class),
$container->get(CustomerRepository::class),
$container->get(ProjectRepository::class),
$container->get(InvoiceTemplateRepository::class),
$container->get(UserRepository::class),
$container->get('event_dispatcher')
$container->get(ServiceInvoice::class), // @phpstan-ignore argument.type
$container->get(CustomerRepository::class), // @phpstan-ignore argument.type
$container->get(ProjectRepository::class), // @phpstan-ignore argument.type
$container->get(InvoiceTemplateRepository::class), // @phpstan-ignore argument.type
$container->get(UserRepository::class), // @phpstan-ignore argument.type
$container->get('event_dispatcher') // @phpstan-ignore argument.type
));
}

View File

@@ -13,6 +13,7 @@ use App\Command\PromoteUserCommand;
use App\Entity\User;
use App\Repository\UserRepository;
use App\User\UserService;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Exception\RuntimeException;
@@ -35,6 +36,7 @@ class PromoteUserCommandTest extends KernelTestCase
$container = self::$kernel->getContainer();
$userService = $container->get(UserService::class);
$this->assertInstanceOf(UserService::class, $userService);
$this->application->add(new PromoteUserCommand($userService));
}
@@ -80,8 +82,10 @@ class PromoteUserCommandTest extends KernelTestCase
$this->assertStringContainsString('[OK] Role "ROLE_TEAMLEAD" has been added to user "john_user".', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
$doctrine = $container->get('doctrine');
/** @var UserRepository $userRepository */
$userRepository = $container->get('doctrine')->getRepository(User::class);
$userRepository = $doctrine->getRepository(User::class);
$user = $userRepository->loadUserByIdentifier('john_user');
self::assertInstanceOf(User::class, $user);
self::assertTrue($user->hasTeamleadRole());
@@ -95,8 +99,10 @@ class PromoteUserCommandTest extends KernelTestCase
$this->assertStringContainsString('[OK] User "john_user" has been promoted as a super administrator.', $output);
$container = self::$kernel->getContainer();
/** @var Registry $doctrine */
$doctrine = $container->get('doctrine');
/** @var UserRepository $userRepository */
$userRepository = $container->get('doctrine')->getRepository(User::class);
$userRepository = $doctrine->getRepository(User::class);
$user = $userRepository->loadUserByIdentifier('john_user');
self::assertInstanceOf(User::class, $user);
self::assertTrue($user->isSuperAdmin());

View File

@@ -42,7 +42,7 @@ class VersionCommandTest extends KernelTestCase
$this->assertEquals($result . PHP_EOL, $output);
}
public function getTestData(): array // @phpstan-ignore-line
public function getTestData(): array // @phpstan-ignore missingType.iterableValue
{
return [
[[], 'Kimai ' . Constants::VERSION . ' by Kevin Papst.'],