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

@@ -20,6 +20,7 @@ use App\Tests\DataFixtures\TimesheetFixtures;
use App\Tests\Mocks\ActivityTestMetaFieldSubscriberMock;
use Doctrine\ORM\EntityManager;
use Symfony\Component\DomCrawler\Field\ChoiceFormField;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpKernel\HttpKernelBrowser;
/**
@@ -203,7 +204,6 @@ class ActivityControllerTest extends ControllerBaseTest
]);
$location = $this->assertIsModalRedirect($client, '/details');
self::assertNotNull($location);
$this->requestPure($client, $location);
$this->assertDetailsPage($client);
@@ -221,7 +221,9 @@ class ActivityControllerTest extends ControllerBaseTest
public function testCreateActionShowsMetaFields(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
self::getContainer()->get('event_dispatcher')->addSubscriber(new ActivityTestMetaFieldSubscriberMock());
$eventDispatcher = self::getContainer()->get('event_dispatcher');
static::assertInstanceOf(EventDispatcher::class, $eventDispatcher);
$eventDispatcher->addSubscriber(new ActivityTestMetaFieldSubscriberMock());
$this->assertAccessIsGranted($client, '/admin/activity/create');
$this->assertTrue($client->getResponse()->isSuccessful());

View File

@@ -19,7 +19,6 @@ use App\Tests\Mocks\SystemConfigurationFactory;
use OneLogin\Saml2\Auth;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Security\Http\SecurityRequestAttributes;
@@ -105,7 +104,6 @@ class SamlControllerTest extends TestCase
$sut = new SamlController($factory, $this->getSamlConfiguration());
$result = $sut->metadataAction();
self::assertInstanceOf(Response::class, $result);
self::assertEquals('xml', $result->headers->get('Content-Type'));
$expected = new \DOMDocument();

View File

@@ -16,6 +16,7 @@ use App\Entity\User;
use App\Form\Type\DateRangeType;
use App\Repository\UserRepository;
use App\Tests\KernelTestTrait;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
@@ -28,6 +29,7 @@ use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Component\HttpFoundation\Test\Constraint as ResponseConstraint;
use Symfony\Component\HttpKernel\HttpKernelBrowser;
use Symfony\Component\Security\Csrf\CsrfToken;
use Symfony\Component\Security\Csrf\CsrfTokenManager;
/**
* ControllerBaseTest adds some useful functions for writing integration tests.
@@ -80,8 +82,10 @@ abstract class ControllerBaseTest extends WebTestCase
protected function loadUserFromDatabase(string $username): User
{
/** @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($username);
self::assertInstanceOf(User::class, $user);
@@ -331,10 +335,8 @@ abstract class ControllerBaseTest extends WebTestCase
foreach ($fieldNames as $name) {
$field = $submittedForm->filter($name);
self::assertNotNull($field, 'Could not find form field: ' . $name);
self::assertGreaterThan(0, $field->count(), 'Could not find form field: ' . $name);
$list = $field->nextAll();
self::assertNotNull($list, 'Form field has no validation message: ' . $name);
$validation = $list->filter('li.text-danger');
if (\count($validation) < 1) {
// decorated form fields with icon have a different html structure
@@ -488,8 +490,12 @@ abstract class ControllerBaseTest extends WebTestCase
{
$request = new Request();
$request->setSession(new Session(new MockArraySessionStorage()));
self::getContainer()->get(RequestStack::class)->push($request);
/** @var RequestStack $stack */
$stack = self::getContainer()->get(RequestStack::class);
$stack->push($request);
/** @var CsrfTokenManager $tokenManager */
$tokenManager = self::getContainer()->get('security.csrf.token_manager');
return self::getContainer()->get('security.csrf.token_manager')->getToken($name);
return $tokenManager->getToken($name);
}
}

View File

@@ -21,6 +21,7 @@ use App\Tests\DataFixtures\TimesheetFixtures;
use App\Tests\Mocks\CustomerTestMetaFieldSubscriberMock;
use Doctrine\ORM\EntityManager;
use Symfony\Component\DomCrawler\Field\ChoiceFormField;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpKernel\HttpKernelBrowser;
/**
@@ -335,7 +336,9 @@ class CustomerControllerTest extends ControllerBaseTest
public function testCreateActionShowsMetaFields(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
self::getContainer()->get('event_dispatcher')->addSubscriber(new CustomerTestMetaFieldSubscriberMock());
/** @var EventDispatcher $dispatcher */
$dispatcher = self::getContainer()->get('event_dispatcher');
$dispatcher->addSubscriber(new CustomerTestMetaFieldSubscriberMock());
$this->assertAccessIsGranted($client, '/admin/customer/create');
$this->assertTrue($client->getResponse()->isSuccessful());

View File

@@ -40,6 +40,9 @@ class InvoiceControllerTest extends ControllerBaseTest
if (is_dir($path)) {
$files = glob($path . '*');
if ($files === false) {
return;
}
foreach ($files as $file) {
unlink($file);
}

View File

@@ -25,6 +25,7 @@ use App\Tests\DataFixtures\TimesheetFixtures;
use App\Tests\Mocks\ProjectTestMetaFieldSubscriberMock;
use Doctrine\ORM\EntityManager;
use Symfony\Component\DomCrawler\Field\ChoiceFormField;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpKernel\HttpKernelBrowser;
/**
@@ -406,7 +407,9 @@ class ProjectControllerTest extends ControllerBaseTest
public function testCreateActionShowsMetaFields(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
self::getContainer()->get('event_dispatcher')->addSubscriber(new ProjectTestMetaFieldSubscriberMock());
/** @var EventDispatcher $dispatcher */
$dispatcher = self::getContainer()->get('event_dispatcher');
$dispatcher->addSubscriber(new ProjectTestMetaFieldSubscriberMock());
$this->assertAccessIsGranted($client, '/admin/project/create');
$this->assertTrue($client->getResponse()->isSuccessful());

View File

@@ -174,7 +174,7 @@ class SelfRegistrationControllerTest extends ControllerBaseTest
$this->assertHasValidationError($client, '/register/', 'form[name=user_registration_form]', $formData, $validationFields);
}
public function getValidationTestData(): array // @phpstan-ignore-line
public function getValidationTestData(): array // @phpstan-ignore missingType.iterableValue
{
return [
[

View File

@@ -29,7 +29,7 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
private function getSystemConfiguration(): SystemConfiguration
{
return static::getContainer()->get(SystemConfiguration::class);
return static::getContainer()->get(SystemConfiguration::class); // @phpstan-ignore return.type
}
public function testIndexAction(): void
@@ -72,7 +72,10 @@ class SystemConfigurationControllerTest extends ControllerBaseTest
$this->assertEquals('POST', $form->getMethod());
}
public function getTestDataForms()
/**
* @return array<array<string>>
*/
public function getTestDataForms(): array
{
return [
['form[name=system_configuration_form_timesheet]', $this->createUrl('/admin/system-config/update/timesheet')],

View File

@@ -20,6 +20,7 @@ use App\Tests\DataFixtures\TagFixtures;
use App\Tests\DataFixtures\TimesheetFixtures;
use App\Tests\Mocks\TimesheetTestMetaFieldSubscriberMock;
use App\Timesheet\DateTimeFactory;
use Symfony\Component\EventDispatcher\EventDispatcher;
/**
* @group integration
@@ -274,7 +275,9 @@ class TimesheetControllerTest extends ControllerBaseTest
public function testCreateActionShowsMetaFields(): void
{
$client = $this->getClientForAuthenticatedUser();
self::getContainer()->get('event_dispatcher')->addSubscriber(new TimesheetTestMetaFieldSubscriberMock());
/** @var EventDispatcher $dispatcher */
$dispatcher = self::getContainer()->get('event_dispatcher');
$dispatcher->addSubscriber(new TimesheetTestMetaFieldSubscriberMock());
$this->request($client, '/timesheet/create');
$this->assertTrue($client->getResponse()->isSuccessful());
@@ -291,8 +294,8 @@ class TimesheetControllerTest extends ControllerBaseTest
$this->assertTrue($client->getResponse()->isSuccessful());
$form = $client->getCrawler()->filter('form[name=timesheet_edit_form]')->form();
$this->assertFalse($form->has('hourlyRate'));
$this->assertFalse($form->has('fixedRate'));
$this->assertFalse($form->has('timesheet_edit_form[hourlyRate]'));
$this->assertFalse($form->has('timesheet_edit_form[fixedRate]'));
}
public function getTrackingModeTestData(): array