Release 2.18 (#4878)

This commit is contained in:
Kevin Papst
2024-06-16 13:15:49 +02:00
committed by GitHub
parent 8792a1df09
commit 987b46bf8f
46 changed files with 1768 additions and 814 deletions

View File

@@ -287,6 +287,7 @@ abstract class APIControllerBaseTest extends ControllerBaseTest
'id' => 'int',
'name' => 'string',
'color' => '@string',
'color-safe' => 'string',
'visible' => 'bool',
];

View File

@@ -64,6 +64,7 @@ class ApiDocControllerTest extends ControllerBaseTest
'/api/activities/{id}/rates',
'/api/activities/{id}/rates/{rateId}',
'/api/config/timesheet',
'/api/config/colors',
'/api/customers',
'/api/customers/{id}',
'/api/customers/{id}/meta',
@@ -78,6 +79,7 @@ class ApiDocControllerTest extends ControllerBaseTest
'/api/version',
'/api/plugins',
'/api/tags',
'/api/tags/find',
'/api/tags/{id}',
'/api/teams',
'/api/teams/{id}',

View File

@@ -25,7 +25,9 @@ class ConfigurationControllerTest extends APIControllerBaseTest
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->assertAccessIsGranted($client, '/api/config/timesheet', 'GET');
$result = json_decode($client->getResponse()->getContent(), true);
$content = $client->getResponse()->getContent();
$this->assertIsString($content);
$result = json_decode($content, true);
$this->assertIsArray($result);
$this->assertNotEmpty($result);
@@ -37,4 +39,53 @@ class ConfigurationControllerTest extends APIControllerBaseTest
$this->assertEquals($expectedKeys, $actual, 'Config structure does not match');
}
public function testIsColorsSecure(): void
{
$this->assertUrlIsSecured('/api/config/colors');
}
public function testGetColors(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->assertAccessIsGranted($client, '/api/config/colors', 'GET');
$content = $client->getResponse()->getContent();
$this->assertIsString($content);
$actual = json_decode($content, true);
$this->assertIsArray($actual);
$this->assertNotEmpty($actual);
$expected = [
'Silver' => '#c0c0c0',
'Gray' => '#808080',
'Black' => '#000000',
'Maroon' => '#800000',
'Brown' => '#a52a2a',
'Red' => '#ff0000',
'Orange' => '#ffa500',
'Gold' => '#ffd700',
'Yellow' => '#ffff00',
'Peach' => '#ffdab9',
'Khaki' => '#f0e68c',
'Olive' => '#808000',
'Lime' => '#00ff00',
'Jelly' => '#9acd32',
'Green' => '#008000',
'Teal' => '#008080',
'Aqua' => '#00ffff',
'LightBlue' => '#add8e6',
'DeepSky' => '#00bfff',
'Dodger' => '#1e90ff',
'Blue' => '#0000ff',
'Navy' => '#000080',
'Purple' => '#800080',
'Fuchsia' => '#ff00ff',
'Violet' => '#ee82ee',
'Rose' => '#ffe4e1',
'Lavender' => '#E6E6FA',
];
$this->assertCount(\count($expected), $actual);
$this->assertEquals($expected, $actual, 'Color structure does not match');
}
}

View File

@@ -54,6 +54,21 @@ class TagControllerTest extends APIControllerBaseTest
$this->assertEquals('Test', $result[9]);
}
public function testFindCollection(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);
$this->importTagFixtures();
$this->assertAccessIsGranted($client, '/api/tags/find', 'GET', ['name' => '2018']);
$content = $client->getResponse()->getContent();
$this->assertNotFalse($content);
$result = json_decode($content, true);
$this->assertIsArray($result);
$this->assertNotEmpty($result);
$this->assertEquals(3, \count($result));
self::assertApiResponseTypeStructure('TagEntity', $result[0]);
}
public function testEmptyCollection(): void
{
$client = $this->getClientForAuthenticatedUser(User::ROLE_USER);

View File

@@ -137,6 +137,7 @@ class SystemConfigurationTest extends TestCase
$this->assertFalse($sut->find('timesheet.rules.allow_future_times'));
$this->assertEquals(99, $sut->find('timesheet.active_entries.hard_limit'));
$this->assertEquals('Maroon|#800000,Brown|#a52a2a,Red|#ff0000,Orange|#ffa500,#ffffff,,|#000000', $sut->getThemeColorChoices());
$this->assertEquals(['Maroon' => '#800000', 'Brown' => '#a52a2a', 'Red' => '#ff0000', 'Orange' => '#ffa500', '#ffffff' => '#ffffff', '#000000' => '#000000'], $sut->getThemeColors());
}
public function testDefaultWithLoader(): void
@@ -160,6 +161,7 @@ class SystemConfigurationTest extends TestCase
$this->assertFalse($sut->find('timesheet.rules.allow_future_times'));
$this->assertTrue($sut->isSamlActive());
$this->assertEquals('Silver|#c0c0c0', $sut->getThemeColorChoices());
$this->assertEquals(['Silver' => '#c0c0c0'], $sut->getThemeColors());
$this->assertEquals('2020-03-27', $sut->getFinancialYearStart());
}

View File

@@ -14,7 +14,7 @@ use App\Entity\Tag;
use App\Entity\Timesheet;
use App\Entity\TimesheetMeta;
use App\Entity\User;
use App\Repository\TagRepository;
use App\Form\Type\TagsType;
use App\Tests\DataFixtures\ActivityFixtures;
use App\Tests\DataFixtures\TagFixtures;
use App\Tests\DataFixtures\TimesheetFixtures;
@@ -51,7 +51,7 @@ class TimesheetControllerTest extends ControllerBaseTest
$start = new \DateTime('first day of this month');
$fixture = new TagFixtures();
$fixture->importAmount(TagRepository::MAX_AMOUNT_SELECT);
$fixture->importAmount(TagsType::MAX_AMOUNT_SELECT);
$fixture->addTagNameToCreate('bar');
$this->importFixture($fixture);
@@ -531,7 +531,7 @@ class TimesheetControllerTest extends ControllerBaseTest
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$fixture = new TagFixtures();
$fixture->importAmount(TagRepository::MAX_AMOUNT_SELECT);
$fixture->importAmount(TagsType::MAX_AMOUNT_SELECT);
$fixture->addTagNameToCreate('two');
$this->importFixture($fixture);
@@ -636,7 +636,7 @@ class TimesheetControllerTest extends ControllerBaseTest
$id = $timesheets[0]->getId();
$fixture = new TagFixtures();
$fixture->importAmount(TagRepository::MAX_AMOUNT_SELECT);
$fixture->importAmount(TagsType::MAX_AMOUNT_SELECT);
$this->importFixture($fixture);
$this->request($client, '/timesheet/' . $id . '/edit');
@@ -717,7 +717,7 @@ class TimesheetControllerTest extends ControllerBaseTest
$this->importFixture($fixture);
$fixture = new TagFixtures();
$fixture->importAmount(TagRepository::MAX_AMOUNT_SELECT);
$fixture->importAmount(TagsType::MAX_AMOUNT_SELECT);
$this->importFixture($fixture);
$this->assertAccessIsGranted($client, '/timesheet/');

View File

@@ -12,7 +12,7 @@ namespace App\Tests\Controller;
use App\Entity\Timesheet;
use App\Entity\TimesheetMeta;
use App\Entity\User;
use App\Repository\TagRepository;
use App\Form\Type\TagsType;
use App\Tests\DataFixtures\TagFixtures;
use App\Tests\DataFixtures\TimesheetFixtures;
use App\Timesheet\DateTimeFactory;
@@ -194,7 +194,7 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
$fixture = new TagFixtures();
$fixture->importAmount(TagRepository::MAX_AMOUNT_SELECT);
$fixture->importAmount(TagsType::MAX_AMOUNT_SELECT);
$this->importFixture($fixture);
$this->request($client, '/team/timesheet/create_mu');
@@ -272,7 +272,7 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
$id = $timesheets[0]->getId();
$fixture = new TagFixtures();
$fixture->importAmount(TagRepository::MAX_AMOUNT_SELECT);
$fixture->importAmount(TagsType::MAX_AMOUNT_SELECT);
$this->importFixture($fixture);
$this->request($client, '/team/timesheet/' . $id . '/edit');
@@ -355,7 +355,7 @@ class TimesheetTeamControllerTest extends ControllerBaseTest
$this->importFixture($fixture);
$fixture = new TagFixtures();
$fixture->importAmount(TagRepository::MAX_AMOUNT_SELECT);
$fixture->importAmount(TagsType::MAX_AMOUNT_SELECT);
$this->importFixture($fixture);
$this->assertAccessIsGranted($client, '/team/timesheet/');

View File

@@ -35,8 +35,11 @@ class TagTest extends TestCase
$sut->setName(null);
$this->assertNull($sut->getName());
$this->assertNull($sut->getColor());
$this->assertIsString($sut->getColorSafe());
$sut->setColor('#fffccc');
$this->assertEquals('#fffccc', $sut->getColor());
$this->assertEquals('#fffccc', $sut->getColorSafe());
}
}

View File

@@ -13,6 +13,7 @@ use App\Entity\Tag;
use App\Form\DataTransformer\TagArrayToStringTransformer;
use App\Repository\TagRepository;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Form\Exception\TransformationFailedException;
/**
* @covers \App\Form\DataTransformer\TagArrayToStringTransformer
@@ -23,6 +24,7 @@ class TagArrayToStringTransformerTest extends TestCase
{
$results = [
(new Tag())->setName('foo'),
'test',
(new Tag())->setName('bar'),
];
@@ -32,10 +34,26 @@ class TagArrayToStringTransformerTest extends TestCase
$this->assertEquals('', $sut->transform([]));
$this->assertEquals('', $sut->transform(null));
$this->assertEquals('', $sut->transform(new \stdClass())); // @phpstan-ignore-line
$actual = $sut->transform($results);
$actual = $sut->transform($results); // @phpstan-ignore-line
$this->assertEquals('foo, bar', $actual);
$this->assertEquals('foo,test,bar', $actual);
}
public function testTransformFails(): void
{
$this->expectException(TransformationFailedException::class);
$results = [
(new Tag())->setName('foo'),
new \stdClass(),
(new Tag())->setName('bar'),
];
$repository = $this->getMockBuilder(TagRepository::class)->disableOriginalConstructor()->getMock();
$sut = new TagArrayToStringTransformer($repository, true);
$sut->transform($results); // @phpstan-ignore-line
}
public function testReverseTransform(): void
@@ -55,7 +73,7 @@ class TagArrayToStringTransformerTest extends TestCase
$this->assertEquals([], $sut->reverseTransform(''));
$this->assertEquals([], $sut->reverseTransform(null));
$actual = $sut->reverseTransform('foo, bar, hello');
$actual = $sut->reverseTransform('foo, bar , hello ');
$this->assertEquals(array_merge($results, [(new Tag())->setName('hello')]), $actual);
}

View File

@@ -243,11 +243,6 @@ parameters:
count: 1
path: API/ApiDocControllerTest.php
-
message: "#^Parameter \\#1 \\$json of function json_decode expects string, string\\|false given\\.$#"
count: 1
path: API/ConfigurationControllerTest.php
-
message: "#^Cannot call method addSubscriber\\(\\) on object\\|null\\.$#"
count: 1
@@ -1473,11 +1468,6 @@ parameters:
count: 1
path: DataFixtures/TestFixture.php
-
message: "#^Argument of an invalid type array\\|null supplied for foreach, only iterables are supported\\.$#"
count: 1
path: DataFixtures/TimesheetFixtures.php
-
message: "#^Method App\\\\Tests\\\\DataFixtures\\\\TimesheetFixtures\\:\\:createTimesheetEntry\\(\\) has parameter \\$tagArray with no value type specified in iterable type array\\.$#"
count: 1