Skip to content

Commit b259a8e

Browse files
author
Holger Lösken
committed
Fix serialization tests
1 parent 7cf6a78 commit b259a8e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

tests/Entity/Post.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace MeiliSearch\Bundle\Test\Entity;
66

77
use Doctrine\Common\Collections\ArrayCollection;
8+
use Doctrine\Common\Collections\Collection;
89
use Doctrine\ORM\Mapping as ORM;
910
use Symfony\Component\Serializer\Annotation\Groups;
1011

@@ -43,13 +44,14 @@ class Post
4344
private ?\DateTime $publishedAt = null;
4445

4546
/**
46-
* @var Comment[]|ArrayCollection
47+
* @var Comment[]|Collection
4748
* @ORM\OneToMany(
4849
* targetEntity="Comment",
4950
* mappedBy="post",
5051
* orphanRemoval=true
5152
* )
5253
* @ORM\OrderBy({"publishedAt": "DESC"})
54+
* @Groups({"searchable"})
5355
*/
5456
private $comments;
5557

@@ -119,7 +121,7 @@ public function setPublishedAt(?\DateTime $publishedAt): Post
119121
return $this;
120122
}
121123

122-
public function getComments(): ?ArrayCollection
124+
public function getComments(): ?Collection
123125
{
124126
return $this->comments;
125127
}

tests/TestCase/SerializationTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public function testSimpleEntityToSearchableArray()
5252
'posts',
5353
$post,
5454
$postMeta,
55-
$this->get('serializer')
55+
$this->get('serializer'),
56+
['useSerializerGroup' => true]
5657
);
5758

5859
$expected = [
@@ -62,8 +63,9 @@ public function testSimpleEntityToSearchableArray()
6263
'publishedAt' => $serializedDateTime,
6364
'comments' => [
6465
[
66+
'id' => null,
6567
'content' => 'a great comment',
66-
'post_title' => 'a simple post',
68+
'publishedAt' => $serializedDateTime,
6769
],
6870
],
6971
];

0 commit comments

Comments
 (0)