beta 3 (#3780)
* merge master - allow to upload twig invoice templates via UI * support adding existing teams with same name * permissions cannot be set right after role was created - fixes #3777 * allow to deactivate unique customer number validation - fixes #3762 * invalid message when trying to edit locked or exported timesheets in calendar - fixes #3766 * updated icons and manifest - fixes #3761
This commit is contained in:
@@ -308,12 +308,6 @@ class ActivityControllerTest extends ControllerBaseTest
|
||||
self::assertStringContainsString('Only visible to the following teams and all admins.', $node->text());
|
||||
$node = $client->getCrawler()->filter('div.card#team_listing_box .card-body table tbody tr');
|
||||
self::assertEquals(1, $node->count());
|
||||
|
||||
// creating the default team a second time fails, as the name already exists
|
||||
$this->request($client, '/admin/activity/1/create_team');
|
||||
$this->assertIsRedirect($client, $this->createUrl('/admin/activity/1/details'));
|
||||
$client->followRedirect();
|
||||
$this->assertHasFlashError($client, 'Changes could not be saved: Team already existing');
|
||||
}
|
||||
|
||||
public function testDeleteAction()
|
||||
|
||||
@@ -283,12 +283,6 @@ class CustomerControllerTest extends ControllerBaseTest
|
||||
self::assertStringContainsString('Only visible to the following teams and all admins.', $node->text(null, true));
|
||||
$node = $client->getCrawler()->filter('div.card#team_listing_box .card-body table tbody tr');
|
||||
self::assertEquals(1, $node->count());
|
||||
|
||||
// creating the default team a second time fails, as the name already exists
|
||||
$this->request($client, '/admin/customer/1/create_team');
|
||||
$this->assertIsRedirect($client, $this->createUrl('/admin/customer/1/details'));
|
||||
$client->followRedirect();
|
||||
$this->assertHasFlashError($client, 'Changes could not be saved: Team already existing');
|
||||
}
|
||||
|
||||
public function testProjectsAction()
|
||||
|
||||
@@ -356,12 +356,6 @@ class ProjectControllerTest extends ControllerBaseTest
|
||||
self::assertStringContainsString('Only visible to the following teams and all admins.', $node->text(null, true));
|
||||
$node = $client->getCrawler()->filter('div.card#team_listing_box .card-body table tbody tr');
|
||||
self::assertEquals(1, $node->count());
|
||||
|
||||
// creating the default team a second time fails, as the name already exists
|
||||
$this->request($client, '/admin/project/1/create_team');
|
||||
$this->assertIsRedirect($client, $this->createUrl('/admin/project/1/details'));
|
||||
$client->followRedirect();
|
||||
$this->assertHasFlashError($client, 'Changes could not be saved: Team already existing');
|
||||
}
|
||||
|
||||
public function testActivitiesAction()
|
||||
|
||||
@@ -309,6 +309,7 @@ class ConfigurationTest extends TestCase
|
||||
1 => 'templates/invoice/renderer/',
|
||||
],
|
||||
'number_format' => '{Y}/{cy,3}',
|
||||
'upload_twig' => true,
|
||||
],
|
||||
'export' => [
|
||||
'documents' => [
|
||||
@@ -430,6 +431,9 @@ class ConfigurationTest extends TestCase
|
||||
],
|
||||
'customer' => [
|
||||
'number_format' => '{cc,4}',
|
||||
'rules' => [
|
||||
'allow_duplicate_number' => false,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
|
||||
namespace App\Tests\EventSubscriber;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\EventSubscriber\AjaxAuthenticationSubscriber;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\SecurityBundle\Security;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
@@ -24,26 +26,46 @@ use Symfony\Component\Security\Core\Exception\AuthenticationExpiredException;
|
||||
*/
|
||||
class AjaxAuthenticationSubscriberTest extends TestCase
|
||||
{
|
||||
public function testGetSubscribedEvents()
|
||||
public function testGetSubscribedEvents(): void
|
||||
{
|
||||
$events = AjaxAuthenticationSubscriber::getSubscribedEvents();
|
||||
$this->assertArrayHasKey(KernelEvents::EXCEPTION, $events);
|
||||
/** @var string $methodName */
|
||||
$methodName = $events[KernelEvents::EXCEPTION][0];
|
||||
$this->assertTrue(method_exists(AjaxAuthenticationSubscriber::class, $methodName));
|
||||
}
|
||||
|
||||
public function getTestHeader()
|
||||
/**
|
||||
* @return array<array<string>>
|
||||
*/
|
||||
public function getTestHeader(): array
|
||||
{
|
||||
yield ['XMLHttpRequest'];
|
||||
yield ['Kimai'];
|
||||
return [
|
||||
['XMLHttpRequest'],
|
||||
['Kimai']
|
||||
];
|
||||
}
|
||||
|
||||
private function getSut(bool $loggedIn = false): AjaxAuthenticationSubscriber
|
||||
{
|
||||
$security = $this->createMock(Security::class);
|
||||
if ($loggedIn) {
|
||||
$user = new User();
|
||||
$security->method('getUser')->willReturn($user);
|
||||
$security->method('isGranted')->willReturn(true);
|
||||
}
|
||||
|
||||
$sut = new AjaxAuthenticationSubscriber($security);
|
||||
|
||||
return $sut;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestHeader
|
||||
*/
|
||||
public function testAuthenticationExpiredException(string $requestedWith)
|
||||
public function testAuthenticationExpiredException(string $requestedWith): void
|
||||
{
|
||||
$sut = new AjaxAuthenticationSubscriber();
|
||||
$sut = $this->getSut();
|
||||
|
||||
$exception = new AuthenticationExpiredException();
|
||||
$kernel = $this->createMock(HttpKernelInterface::class);
|
||||
@@ -65,9 +87,9 @@ class AjaxAuthenticationSubscriberTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getTestHeader
|
||||
*/
|
||||
public function testAuthenticationException(string $requestedWith)
|
||||
public function testAuthenticationException(string $requestedWith): void
|
||||
{
|
||||
$sut = new AjaxAuthenticationSubscriber();
|
||||
$sut = $this->getSut();
|
||||
|
||||
$exception = new AuthenticationException();
|
||||
$kernel = $this->createMock(HttpKernelInterface::class);
|
||||
@@ -89,9 +111,9 @@ class AjaxAuthenticationSubscriberTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getTestHeader
|
||||
*/
|
||||
public function testAccessDeniedException(string $requestedWith)
|
||||
public function testAccessDeniedException(string $requestedWith): void
|
||||
{
|
||||
$sut = new AjaxAuthenticationSubscriber();
|
||||
$sut = $this->getSut();
|
||||
|
||||
$exception = new AccessDeniedException();
|
||||
$kernel = $this->createMock(HttpKernelInterface::class);
|
||||
@@ -109,4 +131,23 @@ class AjaxAuthenticationSubscriberTest extends TestCase
|
||||
self::assertTrue($response->headers->has('Login-Required'));
|
||||
self::assertEquals('1', $response->headers->get('Login-Required'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTestHeader
|
||||
*/
|
||||
public function testAccessDeniedExceptionWithLoggedInUser(string $requestedWith): void
|
||||
{
|
||||
$sut = $this->getSut(true);
|
||||
|
||||
$exception = new AccessDeniedException();
|
||||
$kernel = $this->createMock(HttpKernelInterface::class);
|
||||
$request = new Request();
|
||||
$request->initialize([], [], [], [], [], ['HTTP_X-Requested-With' => $requestedWith]);
|
||||
|
||||
$event = new ExceptionEvent($kernel, $request, 1, $exception);
|
||||
|
||||
$sut->onCoreException($event);
|
||||
|
||||
self::assertNull($event->getResponse());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6037,36 +6037,6 @@ parameters:
|
||||
count: 1
|
||||
path: EventSubscriber/Actions/UsersSubscriberTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\EventSubscriber\\\\AjaxAuthenticationSubscriberTest\\:\\:getTestHeader\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: EventSubscriber/AjaxAuthenticationSubscriberTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\EventSubscriber\\\\AjaxAuthenticationSubscriberTest\\:\\:testAccessDeniedException\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: EventSubscriber/AjaxAuthenticationSubscriberTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\EventSubscriber\\\\AjaxAuthenticationSubscriberTest\\:\\:testAuthenticationException\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: EventSubscriber/AjaxAuthenticationSubscriberTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\EventSubscriber\\\\AjaxAuthenticationSubscriberTest\\:\\:testAuthenticationExpiredException\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: EventSubscriber/AjaxAuthenticationSubscriberTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\EventSubscriber\\\\AjaxAuthenticationSubscriberTest\\:\\:testGetSubscribedEvents\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: EventSubscriber/AjaxAuthenticationSubscriberTest.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$method of function method_exists expects string, array\\<int\\|string, int\\|string\\>\\|int\\|string given\\.$#"
|
||||
count: 1
|
||||
path: EventSubscriber/AjaxAuthenticationSubscriberTest.php
|
||||
|
||||
-
|
||||
message: "#^Method App\\\\Tests\\\\EventSubscriber\\\\EmailSubscriberTest\\:\\:testGetSubscribedEvents\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
|
||||
Reference in New Issue
Block a user