prepare release 1.14 (#2495)

* removed un-maintained docker file
* update all packages
* fix deprecations
* only show one line descriptions for customer, projects and activities
* allow to show export column in timesheet listing
This commit is contained in:
Kevin Papst
2021-04-08 18:07:57 +02:00
committed by GitHub
parent 2ce6e815ff
commit af9dea9226
30 changed files with 920 additions and 739 deletions

View File

@@ -60,21 +60,8 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
return $client;
}
/**
* @param string $url
* @param bool $json
* @return string
*/
protected function createUrl($url, $json = true)
protected function createUrl(string $url): string
{
if ($json) {
if (stripos($url, '?') !== false) {
$url = str_replace('?', '.json?', $url);
} else {
$url .= '.json';
}
}
return '/' . ltrim($url, '/');
}

View File

@@ -26,7 +26,7 @@ class ApiDocControllerTest extends ControllerBaseTest
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->assertAccessIsGranted($client, '/api/doc');
$this->assertStringContainsString('<title>Kimai 2 - API Docs</title>', $client->getResponse()->getContent());
$this->assertStringContainsString('<title>Kimai - API Docs</title>', $client->getResponse()->getContent());
$result = $client->getCrawler()->filter('script#swagger-data');
$swaggerJson = json_decode($result->text(), true);
$tags = [];
@@ -51,17 +51,13 @@ class ApiDocControllerTest extends ControllerBaseTest
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->assertAccessIsGranted($client, '/api/doc.json');
$this->assertStringContainsString('"title":"Kimai 2 - API Docs"', $client->getResponse()->getContent());
$this->assertStringContainsString('"title":"Kimai - API Docs"', $client->getResponse()->getContent());
$result = json_decode($client->getResponse()->getContent(), true);
$this->assertIsArray($result);
$this->assertNotEmpty($result);
}
/**
* @param string $url
* @return string
*/
protected function createUrl($url)
protected function createUrl(string $url): string
{
return '/' . ltrim($url, '/');
}

View File

@@ -0,0 +1,26 @@
<?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\API;
use App\API\NotFoundException;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\API\NotFoundException
*/
class NotFoundExceptionTest extends TestCase
{
public function testConstructor()
{
$sut = new NotFoundException();
self::assertEquals('Not found', $sut->getMessage());
self::assertEquals(404, $sut->getCode());
}
}

View File

@@ -79,11 +79,7 @@ abstract class ControllerBaseTest extends WebTestCase
return $client;
}
/**
* @param string $url
* @return string
*/
protected function createUrl($url)
protected function createUrl(string $url): string
{
return '/' . self::DEFAULT_LANGUAGE . '/' . ltrim($url, '/');
}

View File

@@ -0,0 +1,62 @@
<?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\EventSubscriber;
use App\EventSubscriber\PagerfantaExceptionSubscriber;
use Pagerfanta\Exception\NotValidMaxPerPageException;
use Pagerfanta\Exception\OutOfRangeCurrentPageException;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* @covers \App\EventSubscriber\PagerfantaExceptionSubscriber
*/
class PagerfantaExceptionSubscriberTest extends TestCase
{
public function testGetSubscribedEvents()
{
$events = PagerfantaExceptionSubscriber::getSubscribedEvents();
$this->assertArrayHasKey(KernelEvents::EXCEPTION, $events);
$methodName = $events[KernelEvents::EXCEPTION][0];
$this->assertTrue(method_exists(PagerfantaExceptionSubscriber::class, $methodName));
}
public function testWithExceptions()
{
$sut = new PagerfantaExceptionSubscriber();
$kernel = $this->createMock(HttpKernelInterface::class);
$request = $this->createMock(Request::class);
$exception = new \Exception();
$requestType = HttpKernelInterface::MASTER_REQUEST;
$event = new ExceptionEvent($kernel, $request, $requestType, $exception);
$sut->onCoreException($event);
self::assertSame($exception, $event->getThrowable());
$event = new ExceptionEvent($kernel, $request, $requestType, new NotValidMaxPerPageException('Foo baaaaar!', 999));
$sut->onCoreException($event);
self::assertInstanceOf(NotFoundHttpException::class, $event->getThrowable());
self::assertEquals('Foo baaaaar!', $event->getThrowable()->getMessage());
self::assertEquals(999, $event->getThrowable()->getCode());
self::assertEquals(404, $event->getThrowable()->getStatusCode());
$event = new ExceptionEvent($kernel, $request, $requestType, new OutOfRangeCurrentPageException('Trölölölölölö', 123));
$sut->onCoreException($event);
self::assertInstanceOf(NotFoundHttpException::class, $event->getThrowable());
self::assertEquals('Trölölölölölö', $event->getThrowable()->getMessage());
self::assertEquals(123, $event->getThrowable()->getCode());
self::assertEquals(404, $event->getThrowable()->getStatusCode());
}
}

View File

@@ -77,4 +77,42 @@ class MarkdownExtensionTest extends TestCase
$sut->commentContent("- test\n- foo\n\nfoo __bar__")
);
}
public function testCommentOneLiner()
{
$loader = $this->createMock(ConfigLoaderInterface::class);
$config = new SystemConfiguration($loader, []);
$sut = new MarkdownExtension(new Markdown(), $config);
$loremIpsum = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.';
$this->assertEquals('', $sut->commentOneLiner(null));
$this->assertEquals('', $sut->commentOneLiner(''));
$this->assertEquals('', $sut->commentOneLiner(null, false));
$this->assertEquals('', $sut->commentOneLiner('', true));
$this->assertEquals(
'Lorem ipsum dolor sit amet, consetetur sadipscing &hellip;',
$sut->commentOneLiner($loremIpsum, false)
);
$this->assertEquals(
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. &hellip;',
$sut->commentOneLiner(implode(PHP_EOL, [$loremIpsum, $loremIpsum, $loremIpsum]), true)
);
$this->assertEquals(
'Lorem ipsum dolor sit amet, consetetur sadipscing &hellip;',
$sut->commentOneLiner(implode(PHP_EOL, [$loremIpsum, $loremIpsum, $loremIpsum]), false)
);
$this->assertEquals(
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt',
$sut->commentOneLiner(implode(PHP_EOL, ['Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt']), true)
);
$this->assertEquals(
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt &hellip;',
$sut->commentOneLiner(implode(PHP_EOL, ['Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt', 'ssdf']), true)
);
}
}

View File

@@ -22,7 +22,7 @@ class RuntimeExtensionsTest extends TestCase
{
public function testGetFilters()
{
$expected = ['md2html', 'desc2html', 'comment2html'];
$expected = ['md2html', 'desc2html', 'comment2html', 'comment1line'];
$i = 0;
$sut = new RuntimeExtensions();
@@ -67,6 +67,7 @@ class RuntimeExtensionsTest extends TestCase
$found_md2html = false;
$found_desc2html = false;
$found_comment2html = false;
$found_comment1line = false;
foreach ($filters as $filter) {
switch ($filter->getName()) {
@@ -85,11 +86,17 @@ class RuntimeExtensionsTest extends TestCase
self::assertEquals(['html'], $filters[2]->getSafe(new Node()));
$found_comment2html = true;
break;
case 'comment1line':
self::assertEquals('html', $filters[3]->getPreEscape());
self::assertEquals(['html'], $filters[3]->getSafe(new Node()));
$found_comment1line = true;
break;
}
}
self::assertTrue($found_md2html, 'Missing filter: md2html');
self::assertTrue($found_desc2html, 'Missing filter: desc2html');
self::assertTrue($found_comment2html, 'Missing filter: comment2html');
self::assertTrue($found_comment1line, 'Missing filter: comment1line');
}
}