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

api-platform / core / 7142557150

08 Dec 2023 02:28PM UTC coverage: 36.003% (-1.4%) from 37.36%
7142557150

push

github

web-flow
fix(jsonld): remove link to ApiDocumentation when doc is disabled (#6029)

0 of 1 new or added line in 1 file covered. (0.0%)

2297 existing lines in 182 files now uncovered.

9992 of 27753 relevant lines covered (36.0%)

147.09 hits per line

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

0.0
/src/Serializer/Tests/Fixtures/ApiResource/PropertyCollectionIriOnly.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\Serializer\Tests\Fixtures\ApiResource;
15

16
use ApiPlatform\Metadata\ApiProperty;
17
use ApiPlatform\Metadata\Get;
18
use ApiPlatform\Metadata\GetCollection;
19
use ApiPlatform\Metadata\Post;
20
use Doctrine\Common\Collections\ArrayCollection;
21
use Doctrine\Common\Collections\Collection;
22
use Symfony\Component\Serializer\Annotation\Groups;
23

24
/**
25
 * Assert that a property being a collection set with ApiProperty::UriTemplate to true returns only the IRI of the collection.
26
 */
27
#[
28
    Post,
29
    Get(normalizationContext: ['groups' => ['read']]),
30
    GetCollection(normalizationContext: ['groups' => ['read']]),
UNCOV
31
]
×
32
class PropertyCollectionIriOnly
33
{
34
    private ?int $id = null;
35

36
    #[ApiProperty(uriTemplate: '/property-collection-relations')]
37
    #[Groups('read')]
38
    private Collection $propertyCollectionIriOnlyRelation;
39

40
    /**
41
     * @var array<int, PropertyCollectionIriOnlyRelation> $iterableIri
42
     */
43
    #[ApiProperty(uriTemplate: '/parent/{parentId}/another-collection-operations')]
44
    #[Groups('read')]
45
    private array $iterableIri = [];
46

47
    #[ApiProperty(uriTemplate: '/parent/{parentId}/another-collection-operations/{id}')]
48
    #[Groups('read')]
49
    private PropertyCollectionIriOnlyRelation $toOneRelation;
50

51
    public function __construct()
52
    {
53
        $this->propertyCollectionIriOnlyRelation = new ArrayCollection();
×
54

55
        $this->toOneRelation = new PropertyCollectionIriOnlyRelation();
×
56
        $this->toOneRelation->name = 'Roger';
×
57
        $this->toOneRelation->setPropertyCollectionIriOnly($this);
×
58
    }
59

60
    public function getId(): ?int
61
    {
62
        return $this->id;
×
63
    }
64

65
    /**
66
     * @return Collection<int, PropertyCollectionIriOnlyRelation>
67
     */
68
    public function getPropertyCollectionIriOnlyRelation(): Collection
69
    {
70
        return $this->propertyCollectionIriOnlyRelation;
×
71
    }
72

73
    public function addPropertyCollectionIriOnlyRelation(PropertyCollectionIriOnlyRelation $propertyCollectionIriOnlyRelation): self
74
    {
75
        if (!$this->propertyCollectionIriOnlyRelation->contains($propertyCollectionIriOnlyRelation)) {
×
76
            $this->propertyCollectionIriOnlyRelation->add($propertyCollectionIriOnlyRelation);
×
77
            $propertyCollectionIriOnlyRelation->setPropertyCollectionIriOnly($this);
×
78
        }
79

80
        return $this;
×
81
    }
82

83
    public function removePropertyCollectionIriOnlyRelation(PropertyCollectionIriOnlyRelation $propertyCollectionIriOnlyRelation): self
84
    {
85
        if ($this->propertyCollectionIriOnlyRelation->removeElement($propertyCollectionIriOnlyRelation)) {
×
86
            // set the owning side to null (unless already changed)
87
            if ($propertyCollectionIriOnlyRelation->getPropertyCollectionIriOnly() === $this) {
×
88
                $propertyCollectionIriOnlyRelation->setPropertyCollectionIriOnly(null);
×
89
            }
90
        }
91

92
        return $this;
×
93
    }
94

95
    /**
96
     * @return array<int, PropertyCollectionIriOnlyRelation>
97
     */
98
    public function getIterableIri(): array
99
    {
100
        $propertyCollectionIriOnlyRelation = new PropertyCollectionIriOnlyRelation();
×
101
        $propertyCollectionIriOnlyRelation->name = 'Michel';
×
102

103
        $this->iterableIri = [$propertyCollectionIriOnlyRelation];
×
104

105
        return $this->iterableIri;
×
106
    }
107

108
    public function getToOneRelation(): PropertyCollectionIriOnlyRelation
109
    {
110
        return $this->toOneRelation;
×
111
    }
112
}
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

© 2026 Coveralls, Inc