Release 2.0.16 (#3990)

https://github.com/kimai/kimai/pull/3990
This commit is contained in:
Kevin Papst
2023-04-27 18:48:31 +02:00
committed by GitHub
parent 844062b90e
commit 01e26dca9e
28 changed files with 198 additions and 102 deletions

View File

@@ -481,7 +481,7 @@ class ProfileControllerTest extends ControllerBaseTest
$content = $client->getResponse()->getContent();
self::assertNotFalse($content);
$imgUrl = $this->createUrl('/profile/' . UserFixtures::USERNAME_USER . '/totp.png');
$imgUrl = $this->createUrl('/profile/' . UserFixtures::USERNAME_USER . '/totp-qr-code');
$this->assertStringContainsString('<img src="' . $imgUrl . '" alt="TOTP QR Code" style="max-width: 200px; max-height: 200px;" />', $content);
$formUrl = $this->createUrl('/profile/' . UserFixtures::USERNAME_USER . '/2fa');
@@ -525,14 +525,14 @@ class ProfileControllerTest extends ControllerBaseTest
public function testIsTwoFactorImageSecure(): void
{
$this->assertUrlIsSecured('/profile/' . UserFixtures::USERNAME_USER . '/totp.png');
$this->assertUrlIsSecured('/profile/' . UserFixtures::USERNAME_USER . '/totp-qr-code');
}
public function testTwoFactorImageFailsOnMissingSecret(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->request($client, '/profile/' . UserFixtures::USERNAME_USER . '/totp.png');
$this->request($client, '/profile/' . UserFixtures::USERNAME_USER . '/totp-qr-code');
$this->assertRouteNotFound($client);
}
@@ -546,7 +546,7 @@ class ProfileControllerTest extends ControllerBaseTest
// this is required, so the totp secret is stored in the user entity
$this->request($client, '/profile/' . UserFixtures::USERNAME_USER . '/2fa');
$this->request($client, '/profile/' . UserFixtures::USERNAME_USER . '/totp.png');
$this->request($client, '/profile/' . UserFixtures::USERNAME_USER . '/totp-qr-code');
self::assertTrue($client->getResponse()->isSuccessful());
self::assertEquals('image/png', $client->getResponse()->headers->get('Content-Type'));
}

View File

@@ -62,7 +62,7 @@ class SelfRegistrationControllerTest extends ControllerBaseTest
$this->assertStringContainsString('<input type="email"', $content);
$this->assertStringContainsString('id="user_registration_form_email" name="user_registration_form[email]" required="required"', $content);
$this->assertStringContainsString('<input type="text"', $content);
$this->assertStringContainsString('id="user_registration_form_username" name="user_registration_form[username]" required="required" maxlength="60" pattern=".{2,}"', $content);
$this->assertStringContainsString('id="user_registration_form_username" name="user_registration_form[username]" required="required" maxlength="60" pattern="', $content);
$this->assertStringContainsString('<input type="password"', $content);
$this->assertStringContainsString('id="user_registration_form_plainPassword_first" name="user_registration_form[plainPassword][first]" required="required"', $content);
$this->assertStringContainsString('id="user_registration_form_plainPassword_second" name="user_registration_form[plainPassword][second]" required="required"', $content);

View File

@@ -29,7 +29,9 @@ class ExportServiceCompilerPassTest extends TestCase
private function getContainer(): ContainerBuilder
{
$container = new ContainerBuilder();
$container->setParameter('kimai.export.documents', []); // TODO we could test that as well
$container->setParameter('kimai.export.documents', [
'templates/export/renderer/',
]);
$definition = new Definition(ServiceExport::class);
$container->setDefinition(ServiceExport::class, $definition);
@@ -61,7 +63,8 @@ class ExportServiceCompilerPassTest extends TestCase
$definition = $container->findDefinition(ServiceExport::class);
$methods = $definition->getMethodCalls();
self::assertCount(5, $methods);
self::assertCount(6, $methods);
self::assertTrue($definition->hasMethodCall('addDirectory'));
self::assertTrue($definition->hasMethodCall('addRenderer'));
self::assertTrue($definition->hasMethodCall('addTimesheetExporter'));
self::assertTrue($definition->hasMethodCall('addExportRepository'));

View File

@@ -16,6 +16,8 @@ use App\Export\ServiceExport;
use App\Export\Timesheet\HtmlRenderer as HtmlExporter;
use App\Project\ProjectStatisticService;
use App\Repository\Query\ExportQuery;
use App\Tests\Mocks\Export\HtmlRendererFactoryMock;
use App\Tests\Mocks\Export\PdfRendererFactoryMock;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
@@ -28,9 +30,11 @@ class ServiceExportTest extends TestCase
{
private function createSut(): ServiceExport
{
$sut = new ServiceExport($this->createMock(EventDispatcherInterface::class));
return $sut;
return new ServiceExport(
$this->createMock(EventDispatcherInterface::class),
(new HtmlRendererFactoryMock($this))->create(),
(new PdfRendererFactoryMock($this))->create(),
);
}
public function testEmptyObject()

View File

@@ -0,0 +1,30 @@
<?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\Mocks\Export;
use App\Activity\ActivityStatisticService;
use App\Export\Renderer\HtmlRendererFactory;
use App\Project\ProjectStatisticService;
use App\Tests\Mocks\AbstractMockFactory;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Twig\Environment;
class HtmlRendererFactoryMock extends AbstractMockFactory
{
public function create(): HtmlRendererFactory
{
return new HtmlRendererFactory(
$this->createMock(Environment::class),
$this->createMock(EventDispatcherInterface::class),
$this->createMock(ProjectStatisticService::class),
$this->createMock(ActivityStatisticService::class)
);
}
}

View File

@@ -0,0 +1,28 @@
<?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\Mocks\Export;
use App\Export\Renderer\PdfRendererFactory;
use App\Pdf\HtmlToPdfConverter;
use App\Project\ProjectStatisticService;
use App\Tests\Mocks\AbstractMockFactory;
use Twig\Environment;
class PdfRendererFactoryMock extends AbstractMockFactory
{
public function create(): PdfRendererFactory
{
return new PdfRendererFactory(
$this->createMock(Environment::class),
$this->createMock(HtmlToPdfConverter::class),
$this->createMock(ProjectStatisticService::class),
);
}
}