• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 17158226138

22 Aug 2025 02:38PM UTC coverage: 22.203% (-0.006%) from 22.209%
17158226138

Pull #7303

github

web-flow
Merge d35038aad into 9e382e01b
Pull Request #7303: fix(test): replace `Collection|iterable` with `Collection` and add appropriate PHPDoc tags

0 of 20 new or added lines in 8 files covered. (0.0%)

7 existing lines in 7 files now uncovered.

11699 of 52692 relevant lines covered (22.2%)

24.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Doctrine/Common/Tests/Fixtures/TestBundle/Entity/RelatedDummy.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Doctrine\Common\Tests\Fixtures\TestBundle\Entity;
15

16
use ApiPlatform\Metadata\ApiProperty;
17
use ApiPlatform\Metadata\ApiResource;
18
use ApiPlatform\Metadata\Get;
19
use ApiPlatform\Metadata\GetCollection;
20
use ApiPlatform\Metadata\GraphQl\Mutation;
21
use ApiPlatform\Metadata\GraphQl\Query;
22
use ApiPlatform\Metadata\Link;
23
use Doctrine\Common\Collections\ArrayCollection;
24
use Doctrine\Common\Collections\Collection;
25
use Doctrine\ORM\Mapping as ORM;
26
use Symfony\Component\Serializer\Annotation\Groups;
27
use Symfony\Component\Validator\Constraints as Assert;
28

29
/**
30
 * Related Dummy.
31
 *
32
 * @author Kévin Dunglas <dunglas@gmail.com>
33
 */
34
#[ApiResource(
35
    graphQlOperations: [
×
36
        new Query(name: 'item_query'),
×
37
        new Mutation(name: 'update', normalizationContext: ['groups' => ['chicago', 'fakemanytomany']], denormalizationContext: ['groups' => ['friends']]),
×
38
    ],
×
39
    types: ['https://schema.org/Product'],
×
40
    normalizationContext: ['groups' => ['friends']],
×
41
    filters: ['related_dummy.friends', 'related_dummy.complex_sub_query']
×
42
)]
×
43
#[ApiResource(uriTemplate: '/dummies/{id}/related_dummies{._format}', uriVariables: ['id' => new Link(fromClass: Dummy::class, identifiers: ['id'], fromProperty: 'relatedDummies')], status: 200, types: ['https://schema.org/Product'], filters: ['related_dummy.friends', 'related_dummy.complex_sub_query'], normalizationContext: ['groups' => ['friends']], operations: [new GetCollection()])]
44
#[ApiResource(uriTemplate: '/dummies/{id}/related_dummies/{relatedDummies}{._format}', uriVariables: ['id' => new Link(fromClass: Dummy::class, identifiers: ['id'], fromProperty: 'relatedDummies'), 'relatedDummies' => new Link(fromClass: self::class, identifiers: ['id'])], status: 200, types: ['https://schema.org/Product'], filters: ['related_dummy.friends', 'related_dummy.complex_sub_query'], normalizationContext: ['groups' => ['friends']], operations: [new Get()])]
45
#[ApiResource(uriTemplate: '/related_dummies/{id}/id{._format}', uriVariables: ['id' => new Link(fromClass: self::class, identifiers: ['id'])], status: 200, types: ['https://schema.org/Product'], filters: ['related_dummy.friends', 'related_dummy.complex_sub_query'], normalizationContext: ['groups' => ['friends']], operations: [new Get()])]
46
#[ApiResource(uriTemplate: '/related_owned_dummies/{id}/owning_dummy/related_dummies{._format}', uriVariables: ['id' => new Link(fromClass: RelatedOwnedDummy::class, identifiers: ['id'], fromProperty: 'owningDummy'), 'owningDummy' => new Link(fromClass: Dummy::class, identifiers: [], expandedValue: 'owning_dummy', fromProperty: 'relatedDummies')], status: 200, types: ['https://schema.org/Product'], filters: ['related_dummy.friends', 'related_dummy.complex_sub_query'], normalizationContext: ['groups' => ['friends']], operations: [new GetCollection()])]
47
#[ApiResource(uriTemplate: '/related_owned_dummies/{id}/owning_dummy/related_dummies/{relatedDummies}{._format}', uriVariables: ['id' => new Link(fromClass: RelatedOwnedDummy::class, identifiers: ['id'], fromProperty: 'owningDummy'), 'owningDummy' => new Link(fromClass: Dummy::class, identifiers: [], expandedValue: 'owning_dummy', fromProperty: 'relatedDummies'), 'relatedDummies' => new Link(fromClass: self::class, identifiers: ['id'])], status: 200, types: ['https://schema.org/Product'], filters: ['related_dummy.friends', 'related_dummy.complex_sub_query'], normalizationContext: ['groups' => ['friends']], operations: [new Get()])]
48
#[ApiResource(uriTemplate: '/related_owning_dummies/{id}/owned_dummy/related_dummies{._format}', uriVariables: ['id' => new Link(fromClass: RelatedOwningDummy::class, identifiers: ['id'], fromProperty: 'ownedDummy'), 'ownedDummy' => new Link(fromClass: Dummy::class, identifiers: [], expandedValue: 'owned_dummy', fromProperty: 'relatedDummies')], status: 200, types: ['https://schema.org/Product'], filters: ['related_dummy.friends', 'related_dummy.complex_sub_query'], normalizationContext: ['groups' => ['friends']], operations: [new GetCollection()])]
49
#[ApiResource(uriTemplate: '/related_owning_dummies/{id}/owned_dummy/related_dummies/{relatedDummies}{._format}', uriVariables: ['id' => new Link(fromClass: RelatedOwningDummy::class, identifiers: ['id'], fromProperty: 'ownedDummy'), 'ownedDummy' => new Link(fromClass: Dummy::class, identifiers: [], expandedValue: 'owned_dummy', fromProperty: 'relatedDummies'), 'relatedDummies' => new Link(fromClass: self::class, identifiers: ['id'])], status: 200, types: ['https://schema.org/Product'], filters: ['related_dummy.friends', 'related_dummy.complex_sub_query'], normalizationContext: ['groups' => ['friends']], operations: [new Get()])]
50
#[ORM\Entity]
51
class RelatedDummy extends ParentDummy implements \Stringable
52
{
53
    #[ApiProperty(writable: false)]
54
    #[ORM\Column(type: 'integer')]
55
    #[ORM\Id]
56
    #[ORM\GeneratedValue(strategy: 'AUTO')]
57
    #[Groups(['chicago', 'friends'])]
58
    private $id;
59

60
    /**
61
     * @var string|null A name
62
     */
63
    #[ApiProperty(iris: ['RelatedDummy.name'])]
64
    #[ORM\Column(nullable: true)]
65
    #[Groups(['friends'])]
66
    public $name;
67

68
    #[ApiProperty(deprecationReason: 'This property is deprecated for upgrade test')]
69
    #[ORM\Column]
70
    #[Groups(['barcelona', 'chicago', 'friends'])]
71
    protected $symfony = 'symfony';
72

73
    /**
74
     * @var \DateTime|null A dummy date
75
     */
76
    #[ORM\Column(type: 'datetime', nullable: true)]
77
    #[Assert\DateTime]
78
    #[Groups(['friends'])]
79
    public $dummyDate;
80

81
    #[ORM\ManyToOne(targetEntity: ThirdLevel::class, cascade: ['persist'])]
82
    #[Groups(['barcelona', 'chicago', 'friends'])]
83
    public ?ThirdLevel $thirdLevel = null;
84

85
    /**
86
     * @var Collection<int, RelatedToDummyFriend>|iterable
87
     */
88
    #[ORM\OneToMany(targetEntity: RelatedToDummyFriend::class, cascade: ['persist'], mappedBy: 'relatedDummy')]
89
    #[Groups(['fakemanytomany', 'friends'])]
90
    public Collection|iterable $relatedToDummyFriend;
91

92
    /**
93
     * @var bool|null A dummy bool
94
     */
95
    #[ORM\Column(type: 'boolean', nullable: true)]
96
    #[Groups(['friends'])]
97
    public ?bool $dummyBoolean = null;
98

99
    #[ORM\Embedded(class: 'EmbeddableDummy')]
100
    #[Groups(['friends'])]
101
    public ?EmbeddableDummy $embeddedDummy = null;
102

103
    public function __construct()
104
    {
105
        $this->relatedToDummyFriend = new ArrayCollection();
×
106
        $this->embeddedDummy = new EmbeddableDummy();
×
107
    }
108

109
    public function getId()
110
    {
111
        return $this->id;
×
112
    }
113

114
    public function setId($id): void
115
    {
116
        $this->id = $id;
×
117
    }
118

119
    public function setName($name): void
120
    {
121
        $this->name = $name;
×
122
    }
123

124
    public function getName()
125
    {
126
        return $this->name;
×
127
    }
128

129
    public function getSymfony()
130
    {
131
        return $this->symfony;
×
132
    }
133

134
    public function setSymfony($symfony): void
135
    {
136
        $this->symfony = $symfony;
×
137
    }
138

139
    public function setDummyDate(\DateTime $dummyDate): void
140
    {
141
        $this->dummyDate = $dummyDate;
×
142
    }
143

144
    public function getDummyDate()
145
    {
146
        return $this->dummyDate;
×
147
    }
148

149
    public function isDummyBoolean(): ?bool
150
    {
151
        return $this->dummyBoolean;
×
152
    }
153

154
    /**
155
     * @param bool $dummyBoolean
156
     */
157
    public function setDummyBoolean($dummyBoolean): void
158
    {
159
        $this->dummyBoolean = $dummyBoolean;
×
160
    }
161

162
    public function getThirdLevel(): ?ThirdLevel
163
    {
164
        return $this->thirdLevel;
×
165
    }
166

167
    public function setThirdLevel(?ThirdLevel $thirdLevel = null): void
168
    {
169
        $this->thirdLevel = $thirdLevel;
×
170
    }
171

172
    /**
173
     * Get relatedToDummyFriend.
174
     *
175
     * @return Collection<int, RelatedToDummyFriend>|iterable
176
     */
177
    public function getRelatedToDummyFriend(): Collection|iterable
178
    {
179
        return $this->relatedToDummyFriend;
×
180
    }
181

182
    /**
183
     * Set relatedToDummyFriend.
184
     *
185
     * @param RelatedToDummyFriend $relatedToDummyFriend the value to set
186
     */
187
    public function addRelatedToDummyFriend(RelatedToDummyFriend $relatedToDummyFriend): void
188
    {
NEW
189
        if (!$this->relatedToDummyFriend instanceof Collection) {
×
NEW
190
            return;
×
191
        }
192

UNCOV
193
        $this->relatedToDummyFriend->add($relatedToDummyFriend);
×
194
    }
195

196
    public function getEmbeddedDummy(): EmbeddableDummy
197
    {
198
        return $this->embeddedDummy;
×
199
    }
200

201
    public function setEmbeddedDummy(EmbeddableDummy $embeddedDummy): void
202
    {
203
        $this->embeddedDummy = $embeddedDummy;
×
204
    }
205

206
    public function __toString(): string
207
    {
208
        return (string) $this->getId();
×
209
    }
210
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc