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

@@ -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);
}