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

api-platform / core / 13203378522

07 Feb 2025 03:56PM UTC coverage: 8.501% (+0.7%) from 7.837%
13203378522

push

github

soyuka
Merge 4.1

111 of 490 new or added lines in 51 files covered. (22.65%)

5590 existing lines in 163 files now uncovered.

13345 of 156987 relevant lines covered (8.5%)

22.88 hits per line

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

0.0
/tests/Fixtures/TestBundle/Document/Dummy.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\Tests\Fixtures\TestBundle\Document;
15

16
use ApiPlatform\Metadata\ApiProperty;
17
use ApiPlatform\Metadata\ApiResource;
18
use ApiPlatform\Metadata\Get;
19
use ApiPlatform\Metadata\Link;
20
use Doctrine\Common\Collections\ArrayCollection;
21
use Doctrine\Common\Collections\Collection;
22
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
23
use Symfony\Component\Serializer\Attribute\Context;
24
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
25
use Symfony\Component\Validator\Constraints as Assert;
26

27
/**
28
 * Dummy.
29
 *
30
 * @author Kévin Dunglas <dunglas@gmail.com>
31
 * @author Alexandre Delplace <alexandre.delplacemille@gmail.com>
32
 */
33
#[ApiResource(extraProperties: ['doctrine_mongodb' => ['execute_options' => ['allowDiskUse' => true]], 'standard_put' => false], filters: ['my_dummy.mongodb.boolean', 'my_dummy.mongodb.date', 'my_dummy.mongodb.exists', 'my_dummy.mongodb.numeric', 'my_dummy.mongodb.order', 'my_dummy.mongodb.range', 'my_dummy.mongodb.search', 'my_dummy.property'], normalizationContext: [AbstractNormalizer::IGNORED_ATTRIBUTES => ['dummyDateWithFormat']])]
34
#[ApiResource(uriTemplate: '/related_owned_dummies/{id}/owning_dummy{._format}', uriVariables: ['id' => new Link(fromClass: RelatedOwnedDummy::class, identifiers: ['id'], fromProperty: 'owningDummy')], status: 200, filters: ['my_dummy.mongodb.boolean', 'my_dummy.mongodb.date', 'my_dummy.mongodb.exists', 'my_dummy.mongodb.numeric', 'my_dummy.mongodb.order', 'my_dummy.mongodb.range', 'my_dummy.mongodb.search', 'my_dummy.property'], operations: [new Get()], normalizationContext: [AbstractNormalizer::IGNORED_ATTRIBUTES => ['dummyDateWithFormat']])]
35
#[ApiResource(uriTemplate: '/related_owning_dummies/{id}/owned_dummy{._format}', uriVariables: ['id' => new Link(fromClass: RelatedOwningDummy::class, identifiers: ['id'], fromProperty: 'ownedDummy')], status: 200, filters: ['my_dummy.mongodb.boolean', 'my_dummy.mongodb.date', 'my_dummy.mongodb.exists', 'my_dummy.mongodb.numeric', 'my_dummy.mongodb.order', 'my_dummy.mongodb.range', 'my_dummy.mongodb.search', 'my_dummy.property'], operations: [new Get()], normalizationContext: [AbstractNormalizer::IGNORED_ATTRIBUTES => ['dummyDateWithFormat']])]
36
#[ODM\Document]
37
class Dummy
38
{
39
    #[ODM\Id(strategy: 'INCREMENT', type: 'int', nullable: true)]
40
    private ?int $id = null;
41
    /**
42
     * @var string|null The dummy name
43
     */
44
    #[ApiProperty(iris: ['https://schema.org/name'])]
45
    #[Assert\NotBlank]
46
    #[ODM\Field(type: 'string')]
47
    private $name;
48
    /**
49
     * @var string|null The dummy name alias
50
     */
51
    #[ApiProperty(iris: ['https://schema.org/alternateName'])]
52
    #[ODM\Field(nullable: true)]
53
    private $alias;
54
    /**
55
     * @var array|null foo
56
     */
57
    private ?array $foo = null;
58
    /**
59
     * @var string|null A short description of the item
60
     */
61
    #[ApiProperty(iris: ['https://schema.org/description'])]
62
    #[ODM\Field(type: 'string', nullable: true)]
63
    public $description;
64
    /**
65
     * @var string|null A dummy
66
     */
67
    #[ODM\Field(nullable: true)]
68
    public $dummy;
69
    /**
70
     * @var bool|null A dummy boolean
71
     */
72
    #[ODM\Field(type: 'bool', nullable: true)]
73
    public ?bool $dummyBoolean = null;
74
    /**
75
     * @var \DateTime|null A dummy date
76
     */
77
    #[ApiProperty(iris: ['https://schema.org/DateTime'])]
78
    #[ODM\Field(type: 'date', nullable: true)]
79
    public $dummyDate;
80
    /**
81
     * @var \DateTime|null A dummy date
82
     */
83
    #[Context(denormalizationContext: ['datetime_format' => 'Y-m-d'])]
84
    #[ApiProperty(iris: ['https://schema.org/DateTime'])]
85
    #[ODM\Field(type: 'date', nullable: true)]
86
    private $dummyDateWithFormat;
87
    /**
88
     * @var float|null A dummy float
89
     */
90
    #[ODM\Field(type: 'float', nullable: true)]
91
    public $dummyFloat;
92
    /**
93
     * @var float|null A dummy price
94
     */
95
    #[ODM\Field(type: 'float', nullable: true)]
96
    public $dummyPrice;
97
    #[ODM\ReferenceOne(targetDocument: RelatedDummy::class, storeAs: 'id', nullable: true)]
98
    public ?RelatedDummy $relatedDummy = null;
99
    #[ODM\ReferenceMany(targetDocument: RelatedDummy::class, storeAs: 'id', nullable: true)]
100
    public Collection|iterable $relatedDummies;
101
    #[ODM\Field(type: 'hash', nullable: true)]
102
    public array $jsonData = [];
103
    #[ODM\Field(type: 'collection', nullable: true)]
104
    public array $arrayData = [];
105
    /**
106
     * @var string|null
107
     */
108
    #[ODM\Field(nullable: true)]
109
    public $nameConverted;
110
    /**
111
     * @var RelatedOwnedDummy|null
112
     */
113
    #[ODM\ReferenceOne(targetDocument: RelatedOwnedDummy::class, cascade: ['persist'], mappedBy: 'owningDummy', nullable: true)]
114
    public $relatedOwnedDummy;
115
    /**
116
     * @var RelatedOwningDummy|null
117
     */
118
    #[ODM\ReferenceOne(targetDocument: RelatedOwningDummy::class, cascade: ['persist'], inversedBy: 'ownedDummy', nullable: true, storeAs: 'id')]
119
    public $relatedOwningDummy;
120

121
    public static function staticMethod(): void
122
    {
123
    }
×
124

125
    public function __construct(?\DateTime $dummyDateWithFormat = null)
126
    {
UNCOV
127
        $this->relatedDummies = new ArrayCollection();
×
128
        $this->dummyDateWithFormat = $dummyDateWithFormat;
×
129
    }
130

131
    public function getId(): ?int
132
    {
133
        return $this->id;
×
134
    }
135

136
    public function setId($id): void
137
    {
138
        $this->id = $id;
×
139
    }
140

141
    public function setName($name): void
142
    {
143
        $this->name = $name;
×
144
    }
145

146
    public function getName()
147
    {
148
        return $this->name;
×
149
    }
150

151
    public function setAlias($alias): void
152
    {
153
        $this->alias = $alias;
×
154
    }
155

156
    public function getAlias()
157
    {
158
        return $this->alias;
×
159
    }
160

161
    public function setDescription($description): void
162
    {
163
        $this->description = $description;
×
164
    }
165

166
    public function getDescription()
167
    {
168
        return $this->description;
×
169
    }
170

171
    public function getFoo(): ?array
172
    {
173
        return $this->foo;
×
174
    }
175

176
    public function setFoo(?array $foo = null): void
177
    {
178
        $this->foo = $foo;
×
179
    }
180

181
    public function setDummyDate(?\DateTime $dummyDate = null): void
182
    {
183
        $this->dummyDate = $dummyDate;
×
184
    }
185

186
    public function getDummyDate()
187
    {
UNCOV
188
        return $this->dummyDate;
×
189
    }
190

191
    public function getDummyDateWithFormat()
192
    {
UNCOV
193
        return $this->dummyDateWithFormat;
×
194
    }
195

196
    public function setDummyPrice($dummyPrice)
197
    {
UNCOV
198
        $this->dummyPrice = $dummyPrice;
×
199

200
        return $this;
×
201
    }
202

203
    public function getDummyPrice()
204
    {
205
        return $this->dummyPrice;
×
206
    }
207

208
    public function setJsonData(array $jsonData): void
209
    {
210
        $this->jsonData = $jsonData;
×
211
    }
212

213
    public function getJsonData(): array
214
    {
215
        return $this->jsonData;
×
216
    }
217

218
    public function setArrayData(array $arrayData): void
219
    {
220
        $this->arrayData = $arrayData;
×
221
    }
222

223
    public function getArrayData(): array
224
    {
225
        return $this->arrayData;
×
226
    }
227

228
    public function getRelatedDummy(): ?RelatedDummy
229
    {
230
        return $this->relatedDummy;
×
231
    }
232

233
    public function setRelatedDummy(RelatedDummy $relatedDummy): void
234
    {
235
        $this->relatedDummy = $relatedDummy;
×
236
    }
237

238
    public function addRelatedDummy(RelatedDummy $relatedDummy): void
239
    {
UNCOV
240
        $this->relatedDummies->add($relatedDummy);
×
241
    }
242

243
    public function getRelatedOwnedDummy()
244
    {
UNCOV
245
        return $this->relatedOwnedDummy;
×
246
    }
247

248
    public function setRelatedOwnedDummy(RelatedOwnedDummy $relatedOwnedDummy): void
249
    {
UNCOV
250
        $this->relatedOwnedDummy = $relatedOwnedDummy;
×
UNCOV
251
        if ($this !== $this->relatedOwnedDummy->getOwningDummy()) {
×
UNCOV
252
            $this->relatedOwnedDummy->setOwningDummy($this);
×
253
        }
254
    }
255

256
    public function getRelatedOwningDummy()
257
    {
258
        return $this->relatedOwningDummy;
×
259
    }
260

261
    public function setRelatedOwningDummy(RelatedOwningDummy $relatedOwningDummy): void
262
    {
263
        $this->relatedOwningDummy = $relatedOwningDummy;
×
264
    }
265

266
    public function isDummyBoolean(): ?bool
267
    {
268
        return $this->dummyBoolean;
×
269
    }
270

271
    public function setDummyBoolean(?bool $dummyBoolean): void
272
    {
UNCOV
273
        $this->dummyBoolean = $dummyBoolean;
×
274
    }
275

276
    public function setDummy($dummy = null): void
277
    {
UNCOV
278
        $this->dummy = $dummy;
×
279
    }
280

281
    public function getDummy()
282
    {
UNCOV
283
        return $this->dummy;
×
284
    }
285
}
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