Dont concat if one of the strings is empty during part merge

This commit is contained in:
Jan Böhmer 2023-11-24 23:16:26 +01:00
parent 36879dd7da
commit b9956e38b8
2 changed files with 29 additions and 0 deletions

View file

@ -207,6 +207,13 @@ class EntityMergerHelperTraitTest extends KernelTestCase
$obj2->string_property = 'Test1';
$this->assertSame($obj1, $this->mergeTextWithSeparator($obj1, $obj2, 'string_property', ' # '));
$this->assertSame('Test1', $obj1->string_property);
//Test what happens if the second text is empty
$obj1->string_property = 'Test1';
$obj2->string_property = '';
$this->assertSame($obj1, $this->mergeTextWithSeparator($obj1, $obj2, 'string_property', ' # '));
$this->assertSame('Test1', $obj1->string_property);
}
public function testMergeComment(): void
@ -227,5 +234,11 @@ class EntityMergerHelperTraitTest extends KernelTestCase
$obj2->setComment('Comment1');
$this->assertSame($obj1, $this->mergeComment($obj1, $obj2));
$this->assertSame('Comment1', $obj1->getComment());
//Test what happens if the second comment is empty
$obj1->setComment('Comment1');
$obj2->setComment('');
$this->assertSame($obj1, $this->mergeComment($obj1, $obj2));
$this->assertSame('Comment1', $obj1->getComment());
}
}